I am recently reading about Node.js and got an interesting statement about JavaScript and Internet Explorer:
Internet Explorer doesn’t actually support JavaScript or ECMAScript; it supports a language variety called JScript. In recent years, JScript has fully supported the ECMAScript 3 standard and has some ECMAScript 5 support. However, JScript also implements proprietary extensions in the same way that Mozilla JavaScript does and has features that ECMAScript does not.
Source: http://chimera.labs.oreilly.com/books/1234000001808/ch01.html#chap2_id35941400
Frankly speaking I am totally unable to understand the above statement. I know Microsoft has its own VBScript and it allowed JavaScript in IE that is why JS is more popular than any other scripting language. Is this statement true? If yes then the scripting engine of IE does the translations of native JavaScript to JScript or what is the other case?
ECMAScript is the official standard, JavaScript and JScript are implementations of that standard. Just like CPython and Jython are implementations of Python.
As so often if it's about browsers, they both don't necessarily fully support the standard or provide additional, non-standard features, partly because they started evolving when an official standard didn't exist yet.
From Wikipedia about JScript:
[Microsoft] did not want to deal with Sun about the trademark issue, and so they called their implementation JScript. A lot of people think that JScript and JavaScript are different but similar languages. That's not the case. They are just different names for the same language, and the reason the names are different was to get around trademark issues
From the Microsoft documentation about JScript:
JScript is the Microsoft implementation of the ECMA 262 language specification (ECMAScript Edition 3). With only a few minor exceptions (to maintain backwards compatibility), JScript is a full implementation of the ECMA standard.
well, this mainly depends on the version of IE you are using, as you havent mentioned that no one can say that for sure
I think it is not like that instead Microsoft gives you an option to enable Javascript on your IE like this:
Pull down your TOOLS menu
Select Internet Options...
Click the Security tab on the top of the resulting window
Click the Custom Level button
Scroll the list down to the entry for Active Scripting
Check the Enable radio button.
Click OK in all dialogs.
Also Jscript is same as Javascript
JScript is Microsoft's dialect of the ECMAScript standard[2] that is
used in Microsoft's Internet Explorer.
JScript is implemented as a
Active Scripting engine. This means that it can be "plugged in" to OLE
Automation applications that support Active Scripting, such as
Internet Explorer, Active Server Pages, and Windows Script Host.[3] It
also means such applications can use multiple Active Scripting
languages (e.g., JScript, VBScript, PerlScript, etc.).
Related
I'm wondering if there's a standardized file extension for ES6 yet. So far I've seen .es6 and .es6.js as two options, but I'm curious if one is generally better supported by third party packages and tools. And if Mozilla is leaning a particular direction.
There's no formal ES6/JS extension, although majority of people seem to prefer .js. ECMAScript specific suffixes aren't common.
Mozilla is using two extensions within Firefox and FirefoxOS: .js and .jsm. No ECMA Script specific suffixes.
For Gecko (the layout engine written largely in JS), they use both .js and .jsm. Example: one of the DOM modules source code.
In some other subprojects, such as Gaia, they use .js only. Example: "system" app for Firefox OS.
Note: .jsm is something specific to Gecko - it's a Javascript module.
Note: ECMAScript 6 is a standard that is later implemented in Firefox as Javascript. So those two terms are closely related, and are almost synonyms (source).
Heads up: source code on the Gecko side has the syntax that is plain JS with some extensions - some of which ended up in ECMA Script 6, some not. In general, though, Mozillians tend to follow ECMA Script spec closely. Possible differences are listed here.
Here's something I've been pondering after countless hours fixing JS to be cross-browser compatible (mostly IE): Why isn't Javascript consistent accross browsers?
I mean, why can't JS be nice like Java and Flash? Instead, we have to resort to frameworks like jQuery. Don't get me wrong, they make my life easier - but why do they even exist in the first place?
Is there a historical reason for this? Do companies rolling out browsers just ship their own JS engine? What are the politics that make standardization so difficult?
(Note: I understand that a good part of the problem is DOM related, but the question remains).
The Javascript core language for the most part is consistent ( Referring to ECMAScript version 3 released in 1999. )
It's the DOM implementations that cause headaches. Partly because at one point there was no DOM specification so browsers could do whatever the hell they wanted in terms of making up the rules for which to access and manipulate html elements in a web page.
For example:
window.addEventListener for DOM supporting browsers, while window.attachEvent for IE.
textContent for DOM supporting browsers, innerText for IE.
Memory leakage for attached event handlers in IE so you have to unload them manually
getElementById is buggy in IE and Opera because it returns elements by name
getAttribute('href') returns inconsistent values
There are also issues relating to the browser's CSS support.
IE6 doesn't support native PNGs so you are forced to use the filter library
Buggy animation in IE dealing with filter opacity
Language core inconsistencies would be things like
Inconsistencies between regex engines
But yeah, in short the point is that before, there was no standard. Since then, the w3 came up with standards, but every browser vendor has its own way of dealing with implementing it. There's no governing body that forces the vendors to fully apply the spec.
Do companies rolling out browsers just ship their own JS engine?
Yup, that's probably the main reason. There is no unified JS engine; there are various implementations of ECMAScript.
Browsers roll their own implementation, plain and simple. It's the same reason why rendering and CSS and all that are different across browsers. Java/Flash/etc. are more universal because they're abstracted out of the browser and accessed via a plugin of some sort. But their actual core implementations are separate from the browser and controlled by a single vendor.
To add to the other answers: there is a historical reason for this. I can write this myself, but quoting Wikipedia is easier on the fingers:
JavaScript was originally developed by
Brendan Eich of Netscape under the
name Mocha, which was later renamed to
LiveScript, and finally to JavaScript.
LiveScript was the official name for
the language when it first shipped in
beta releases of Netscape Navigator
2.0 in September 1995, but it was renamed JavaScript in a joint
announcement with Sun Microsystems on
December 4, 1995 when it was deployed
in the Netscape browser version 2.0B3.
[…]
JavaScript very quickly gained
widespread success as a client-side
scripting language for web pages. As a
consequence, Microsoft developed a
compatible dialect of the language,
naming it JScript to avoid trademark
issues. JScript added new date methods
to fix the non-Y2K-friendly methods in
JavaScript, which were based on
java.util.Date. JScript was included
in Internet Explorer 3.0, released in
August 1996. The dialects are
perceived to be so similar that the
terms "JavaScript" and "JScript" are
often used interchangeably. Microsoft,
however, notes dozens of ways in which
JScript is not ECMA-compliant.
In November, 1996 Netscape announced
that it had submitted JavaScript to
Ecma International for consideration
as an industry standard, and
subsequent work resulted in the
standardized version named ECMAScript.
As you can see, the standard, ECMAScript, was developed later than the original language. It's just a matter of adapting this standard in the current implementations of web browsers, that's still going on, as is the development of ECMAScript itself (e.g., see the specification of ECMAScript 5, published December 2009).
Perl, Ruby, Python, Javascript / ecmascript, PHP are all similar in the sense of being open source, open documentation, multi-platform, etc.
Perl has http://www.perl.org
Ruby has http://www.ruby-lang.org
Python has http://www.python.org
PHP has http://php.net
Is there a "home" for javascript in the same sense as these other languages?
When I say "home" I mean the go-to place for official documentation, specifications, source code of the language, examples, etc.
There's “JavaScript” the Mozilla-specific scripting language, for which the nearest to a home would probably be MDC, in particular the Core reference — though this has not been kept up-to-date with newer language developments, sadly.
And then there's ECMAScript, the standardised language that grew out of early Netscape work on JavaScript, and which is the basis for Mozilla's modernised JavaScript, IE's JScript, and the implementations in Opera, V8 (Chrome) and Squirrelfish (Safari), not to mention Flash's ActionScript.
This is driven by ECMA TC39 which produces the ECMA-262 standard. As a pure standards group, their materials are dry, unfriendly, and not really a suitable ‘home’ site at all. But if you want official that's all there is.
There is a real gap here for a user-readable doc site that covers standard ECMAScript, rather each vendor's own extended quirky version of it. (The canonical ECMA-262-5 is quite unreadable, even by the standards of standards documents.)
A very good place is https://developer.mozilla.org/en/JavaScript - they have tons of documentation there.
I will get burnt at the stake for this link, but for the 60%+ internet users out there who are using Internet Explorer (still), the MSDN reference is actually well documented.
It's the home of Javascript in the same way Simon Cowell is an authority on music though.
The Mozilla Foundation continues to add new language features to JavaScript. They're up to version 1.8 now where 1.5 was more or less the ECMA baseline.
However, Firefox is the only browser that supports the latest version and IE is firmly stuck at a 1.5-equivalent JScript.
What purpose do the Firefox-only extensions serve? Or are they just lying dormant until (and if) the rest of the browsers catch up?
Firefox, Thunderbird, and other XUL apps also have large portions of themselves written in JavaScript. A more featureful JavaScript means a better development environment for Firefox and other Mozilla apps.
Extending the language is a good idea, even if only one browser is doing it - eventually it will prove itself and be made into the standard at which time other browsers will have to catch up.
Otherwise, how can progress be made - Microsoft does this all the time: would XMLHttpRequest have ever made it into the standards if Internet Explorer wouldn't have implemented it first?
From the Mozilla perspective the purpose of these changes, except for adding more capabilities for use by web developers, is to lead up to JavaScript 2.0, that is being developed as the next revision of ECMA 262 (revision 4) TC39 workgroup.
Future browsers will support JavaScript 2.0. In the mean time, developers are invited to take advantage of these extra features - natively in Firefox and using JavaScript libraries that provide backward compatibility with Internet Explorer. I find this very useful.
Also, it may be interesting to note that Webkit (the engine developed by KDE and used by Safari, Chrome and several free software browsers) supports JavaScript 1.7.
The biggest reason at the moment for improved JavaScript is for extension writers, who need not worry about cross-browser compatiblity.
JavaScript is a trademark by Sun which was licensed to Netscape and is now held by the Mozilla Foundation. Microsoft has their own implementation of the language called JScript, but there are others (eg. DMDScript).
ECMAScript was an afterthought to add a common baseline to the various implementations. So it's only natural that language development continues outside the standards committee, which is free to add the changes pioneered by the implementors in future revisions of the standard (eg the array extras introduces in JS1.6 will be in ES3.1).
I have always wondered WHaT tHE HecK?!? is the difference between JScript and JavaScript.
Just different names for what is really ECMAScript. John Resig has a good explanation.
Here's the full version breakdown:
IE 6-7 support JScript 5 (which is equivalent to ECMAScript 3, JavaScript 1.5)
IE 8 supports JScript 6 (which is equivalent to ECMAScript 3, JavaScript 1.5 - more bug fixes over JScript 5)
Firefox 1.0 supports JavaScript 1.5 (ECMAScript 3 equivalent)
Firefox 1.5 supports JavaScript 1.6 (1.5 + Array Extras + E4X + misc.)
Firefox 2.0 supports JavaScript 1.7 (1.6 + Generator + Iterators + let + misc.)
Firefox 3.0 supports JavaScript 1.8 (1.7 + Generator Expressions + Expression Closures + misc.)
The next version of Firefox will support JavaScript 1.9 (1.8 + To be determined)
Opera supports a language that is equivalent to ECMAScript 3 + Getters and Setters + misc.
Safari supports a language that is equivalent to ECMAScript 3 + Getters and Setters + misc.
As far as I can tell, two things:
ActiveXObject constructor
The idiom f(x) = y, which is roughly equivalent to f[x] = y.
From Wikipedia: http://en.wikipedia.org/wiki/Jscript
JScript is the Microsoft dialect of
the ECMAScript scripting language
specification.
JavaScript (the Netscape/Mozilla
implementation of the ECMA
specification), JScript, and
ECMAScript are very similar languages.
In fact the name "JavaScript" is often
used to refer to ECMAScript or
JScript.
Microsoft uses the name JScript for its implementation to avoid trademark issues (JavaScript is a trademark of Oracle Corporation).
JScript is Microsoft's implementation of the ECMAScript specification. JavaScript is the Mozilla implementation of the specification.
Javascript, the language, came first, from Netscape.
Microsoft reverse engineered Javascript and called it JScript to avoid trademark issues with Sun. (Netscape and Sun were partnered up at the time, so this was less of an issue)
The languages are identical, both are dialects of ECMA script, the after-the-fact standard.
Although the languages are identical, since JScript runs in Internet Explorer, it has access to different objects exposed by the browser (such as ActiveXObject)
JScript is the Microsoft implementation of Javascript
According to this article:
JavaScript is a scripting language developed by Netscape Communications designed for developing client and server Internet applications. Netscape Navigator is designed to interpret JavaScript embedded into Web pages. JavaScript is independent of Sun Microsystem's Java language.
Microsoft JScript is an open implementation of Netscape's JavaScript. JScript is a high-performance scripting language designed to create active online content for the World Wide Web. JScript allows developers to link and automate a wide variety of objects in Web pages, including ActiveX controls and Java programs. Microsoft Internet Explorer is designed to interpret JScript embedded into Web pages.
Long time ago, all browser providers were making JavaScript engines for their browsers and only they and god knew what was happening inside this. One beautiful day, ECMA international came and said: let's make engines based on common standard, let's make something general to make life more easy and fun, and they made that standard.
Since all browser providers make their JavaScript engines based on ECMAScript core (standard).
For example, Google Chrome uses V8 engine and this is open source. You can download it and see how C++ program translates a command 'print' of JavaScript to machine code.
Internet Explorer uses JScript (Chakra) engine for their browser and others do so and they all uses common core.
There are some code differences to be aware of.
A negative first parameter to subtr is not supported, e.g. in Javascript: "string".substr(-1) returns "g", whereas in JScript: "string".substr(-1) returns "string"
It's possible to do "string"[0] to get "s" in Javascript, but JScript doesn't support such a construct. (Actually, only modern browsers appear to support the "string"[0] construct.
Wikipedia has this to say about the differences.
In general JScript is an ActiveX scripting language that is probably interpreted as JavaScript by non-IE browsers.
JScript and Javascript is TOTALLY different scripting languages. Javascript runs on the browser, but JScript can use ActiveX objects and has almost total control on your operating system if you've ran it, it can delete files, run or write files, download files from the web(via Powershell) run cmd commands etc. JScript is almost the same thing as VBScript, but has different syntax.
Jscript is a .NET language similar to C#, with the same capabilities and access to all the .NET functions.
JavaScript is run on the ASP Classic server. Use Classic ASP to run the same JavaScript that you have on the Client (excluding HTML5 capabilities). I only have one set of code this way for most of my code.
I run .ASPX JScript when I require Image and Binary File functions, (among many others) that are not in Classic ASP. This code is unique for the server, but extremely powerful.
JScript is Microsoft's equivalent of JavaScript.
Java is an Oracle product and used to be a Sun product.
Oracle bought Sun.
JavaScript + Microsoft = JScript