JavaScript and JScript : What's the Difference?

Two Different but Similar Languages for Web Browsers

Woman using a laptop computer in darkness with her hands illuminated by the computer screen isolated on black background
Alex Maxim / Getty Images

Netscape developed the original version of JavaScript for the second version of their popular browser. Initially, Netscape 2 was the only browser to support a scripting language and that language was originally called LiveScript. It was soon renamed JavaScript. This was in an attempt to cash in on some of the publicity that Sun's Java programming language was getting at that time.

While JavaScript and Java are superficially alike they are completely different languages. This naming decision has caused numerous problems for beginners with both languages who continually get them confused. Just remember that JavaScript is not Java (and vice versa) and you will avoid a lot of confusion.

Microsoft was attempting to capture market share from Netscape at the time Netscape created JavaScript and so with Internet Explorer 3 Microsoft introduced two scripting languages. One of these they based on visual basic and it was given the name VBscript. The second was a JavaScript lookalike which Microsoft called JScript.

In order to try to outdo Netscape, JScript had a number of additional commands and features available that were not in JavaScript. JScript also had interfaces to Microsoft's ActiveX functionality as well.

Hiding from Old Browsers

Since Netscape 1, Internet Explorer 2, and other early browsers didn't understand either JavaScript or JScript it became a common practice to place all of the content of the script inside of an HTML comment so as to hide the script from older browsers. New browsers even if they couldn't handle scripts were designed to recognise the script tags themselves and so hiding the script by placing it in a comment was not required for any browsers released after IE3.

Unfortunately by the time that the extremely early browsers ceased to be used people had forgotten the reason for the HTML comment and so many people new to JavaScript still include these now completely unnecessary tags. In fact including the HTML comment can cause problems with modern browsers. If you use XHTML instead of HTML including the code inside a comment like that will have the effect of making the script a comment rather than a script. Many modern Content Management Systems (CMS) will do the same.

Language Development

Over time both JavaScript and JScript were extended to introduce new commands to improve their ability to interact with web pages. Both languages added new features that worked differently than the corresponding feature (if any) in the other language.

The way the two languages work was just similar enough that it was possible to use browser sensing to work out whether the browser was Netscape or IE. The appropriate code for that browser could then be run. As the balance shifted toward IE gaining an equal share of the browser market with Netscape this incompatibility needed a resolution.

Netscape's solution was to hand over control of JavaScript to the European Computer Manufacturers Association (ECMA). The Association formalized the JavaScript standards under the name ECMAscipt. At the same time, the World Wide Web Consortium (W3C) commenced work on a standard Document Object Model (DOM) that would be used to allow JavaScript and other scripting languages full access to manipulate all of the content of the page instead of the limited access that it had up until that time.

Before the DOM standard was complete both Netscape and Microsoft released their own versions. Netscape 4 came with its own document.layer DOM and Internet Explorer 4 came with its own document.all DOM. Both of these document object models were made obsolete when people ceased using either of those browsers as all browsers since then have implemented the standard DOM.

Standards

ECMAscript and the introduction of the standard DOM in all of the version five and more recent browsers removed most of the incompatibilities between Javascript and JScript. While these two languages still have their differences it is now possible to write code that can run both as JScript in Internet Explorer and as JavaScript in all of the other modern browsers with very little feature sensing needed. Support for specific features may vary between browsers but we can test for those differences by making use of a feature built into both languages from the start that allows us to test if the browser supports a specific feature. By testing the specific features that not all browsers support we will be able to determine what code is appropriate to run in the current browser.

Differences

The biggest difference now between JavaScript and JScript are all of the additional commands that JScript supports that allow access to ActiveX and the local computer. These commands are intended for use on intranet sites where you know the configuration of all of the computers and that they are all running Internet Explorer.

There are still a few areas remaining where JavaScript and JScript differ in the means that they provide to perform a particular task. Except in these situations, the two languages can be considered to be equivalent to one another and so unless otherwise specified all of the references to JavaScript that you see will also usually include JScript.

Format
mla apa chicago
Your Citation
Chapman, Stephen. "JavaScript and JScript : What's the Difference?" ThoughtCo, Aug. 27, 2020, thoughtco.com/javascript-and-jscript-whats-the-difference-2037681. Chapman, Stephen. (2020, August 27). JavaScript and JScript : What's the Difference? Retrieved from https://www.thoughtco.com/javascript-and-jscript-whats-the-difference-2037681 Chapman, Stephen. "JavaScript and JScript : What's the Difference?" ThoughtCo. https://www.thoughtco.com/javascript-and-jscript-whats-the-difference-2037681 (accessed March 19, 2024).