ecma262

What is the difference between JavaScript and ECMAScript?

我的未来我决定 提交于 2019-11-26 14:48:10
What's the difference between ECMAScript and JavaScript? From what I've deduced, ECMAScript is the standard and JavaScript is the implementation. Is this correct? Ryan Florence ECMAScript is the language, whereas JavaScript, JScript, and even ActionScript 3 are called "dialects". Wikipedia sheds some light on this. I think a little history lesson is due. JavaScript was originally named Mocha and changed to Livescript but ultimately became JavaScript. It's important to note that JavaScript came before ECMAscript and the history will tell you why. To start from the beginning, JavaScript derived

What's a valid left-hand-side expression in JavaScript grammar?

一曲冷凌霜 提交于 2019-11-26 12:12:50
问题 Okay, we all know what the valid left-hand-side expressions are. Kind of.* But, looking at the definition from the ECMA-Script standard, I\'m very confused: LeftHandSideExpression : NewExpression CallExpression Is that just an error in the definition, or am I getting something wrong here? I mean, doesn\'t that actually mean that new Object = 1; // NewExpression AssignmentOperator PrimaryExpression function () { return foo; }() = 1;// CallExpression AssignmentOperator PrimaryExpression are

Javascript IN operator compatibility

我的梦境 提交于 2019-11-26 11:28:37
问题 Can someone tell me since which ECMA version the IN operator is available and which browsers (versions) support it ? Explanation: The IN-operator can be used like the following: var myObject = { Firstname: \'Foo\', Lastname: \'Bar\' }; if(\'Lastname\' in myObject){ // Lastname is an attribute of myObject } 回答1: It is defined in ECMAScript 3rd edition. It is available in IE 5.5+ and all in-use versions of Firefox, Chrome, Opera and Safari. You can use it safe in the knowledge that it will work

Getting a reference to the global object in an unknown environment in strict mode

不羁岁月 提交于 2019-11-26 09:03:01
问题 What is the recommended way to get a handle to the global object in ES5 strict mode in an unknown host environment ? ECMAScript doesn\'t provide a built-in way to reference the global object that I\'m aware of. If it does, this is the answer I\'m looking for. In a known environment , the global object usually has a self-referential property. Since the global object is the VO for the global scope, properties of the global object are global variables, so we can use them get a handle to the

Object.defineProperty in ES5?

二次信任 提交于 2019-11-26 08:30:25
问题 I\'m seeing posts about a \'new\' Object.create that makes enumeration configurable. However, it relies on a Object.defineProperty method. I can\'t find a cross browser implementation for this method. Are we stuck writing for the old Object.create? I can\'t write things that won\'t work in IE6/7. 回答1: There are several things that you can't emulate from the ECMAScript 5 Object.create method on an ECMAScript 3 environment. As you saw, the properties argument will give you problems since in E3

JSON left out Infinity and NaN; JSON status in ECMAScript?

徘徊边缘 提交于 2019-11-26 04:41:52
问题 Any idea why JSON left out NaN and +/- Infinity? It puts Javascript in the strange situation where objects that would otherwise be serializable, are not, if they contain NaN or +/- infinity values. Looks like this has been cast in stone: see RFC4627 and ECMA-262 (section 24.3.2, JSON.stringify, NOTE 4, page 507 at last edit): Finite numbers are stringified as if by calling ToString(number) . NaN and Infinity regardless of sign are represented as the String null . 回答1: Infinity and NaN aren't

What is the difference between JavaScript and ECMAScript?

余生长醉 提交于 2019-11-26 04:01:56
问题 What\'s the difference between ECMAScript and JavaScript? From what I\'ve deduced, ECMAScript is the standard and JavaScript is the implementation. Is this correct? 回答1: ECMAScript is the language, whereas JavaScript, JScript, and even ActionScript 3 are called "dialects". Wikipedia sheds some light on this. 回答2: I think a little history lesson is due. JavaScript was originally named Mocha and changed to Livescript but ultimately became JavaScript. It's important to note that JavaScript came

Indirect function call in JavaScript

本小妞迷上赌 提交于 2019-11-26 03:56:25
问题 There are things like f.call(...) f.apply(...) But then there\'s this (1, alert)(\'Zomg what is this????!!!11\') \"1\" does not seem to mean much in this context, the following works just fine: (null, alert)(\'Zomg what is this????!!!11\') (1, null, alert)(\'Zomg what is this????!!!11\') (undefined, alert)(\'Zomg what is this????!!!11\') Could you point to a specific part of ECMAScript which describes that syntax? 回答1: You are just using The Comma Operator. This operator only evaluates its

Why was the arguments.callee.caller property deprecated in JavaScript?

孤街醉人 提交于 2019-11-25 22:44:23
问题 Why was the arguments.callee.caller property deprecated in JavaScript? It was added and then deprecated in JavaScript, but it was omitted altogether by ECMAScript. Some browser (Mozilla, IE) have always supported it and don\'t have any plans on the map to remove support. Others (Safari, Opera) have adopted support for it, but support on older browsers is unreliable. Is there a good reason to put this valuable functionality in limbo? (Or alternately, is there a better way to grab a handle on