ecma262

Is JavaScript's double equals (==) always symmetric?

我与影子孤独终老i 提交于 2019-11-30 05:39:28
There are many cases in which JavaScript's type-coercing equality operator is not transitive. For example, see " JavaScript equality transitivity is weird ." However, are there any cases in which == isn't symmetric ? That is, where a == b is true and b == a is false ? SLaks In Javascript, == is always symmetric . The spec says : NOTE 2 The equality operators maintain the following invariants: A != B is equivalent to !(A == B) . A == B is equivalent to B == A , except in the order of evaluation of A and B . It's supposed to be symmetric. However, there is an asymmetric case in some versions of

JavaScript Closures - Using the ECMA Spec, please explain how the closure is created and maintained

瘦欲@ 提交于 2019-11-30 04:30:33
I'm reading about JavaScript closures . I'm familiar with Execution Contexts , how the Lexical Environment is maintained, and very familiar with Lexical Scoping . I want to know how closures in JavaScript are created and maintained . Sometimes it's hard for me to grasp such important concepts without knowing how it is actually doing it. I know that, according to Wikipedia, a closure is is a function or reference to a function together with a referencing environment—a table storing a reference to each of the non-local variables (also called free variables) of that function. But my question is,

EcmaScript 5 browser implementation

我的未来我决定 提交于 2019-11-29 22:53:07
So Safari and Chrome have started in their betas to implement some ES5 stuff. For instance Object.create is in them. Do any of you know if there is a website that shows the progress made in the browsers? ATM i need to use Object.freeze, and wanted to see which browsers (if any) supported that yet. Tihauan Here's an up to date list for major engines: http://kangax.github.com/es5-compat-table/ 来源: https://stackoverflow.com/questions/2280115/ecmascript-5-browser-implementation

Activation and Variable Object in JavaScript?

白昼怎懂夜的黑 提交于 2019-11-29 20:12:02
Is the term "activation object" just another name of "variable object" or is there actually any difference between them? I have been reading a few JavaScript articles about how variable scopes are formed in an execution context, and from my point of view it seems that in most of the articles they use these two terms interchangeably. Well, I just learned something :). From this article , it would appear that within the execution context of a function , the Activation Object is used as the Variable Object: When an execution context is created a number of things happen in a defined order. First,

Is there any way to check if strict mode is enforced?

元气小坏坏 提交于 2019-11-29 19:56:26
Is there anyway to check if strict mode 'use strict' is enforced , and we want to execute different code for strict mode and other code for non-strict mode. Looking for function like isStrictMode();//boolean The fact that this inside a function called in the global context will not point to the global object can be used to detect strict mode: var isStrict = (function() { return !this; })(); Demo: > echo '"use strict"; var isStrict = (function() { return !this; })(); console.log(isStrict);' | node true > echo 'var isStrict = (function() { return !this; })(); console.log(isStrict);' | node false

Why is this configurable property not deletable?

自古美人都是妖i 提交于 2019-11-29 07:02:42
Configurable properties seem to be deletable: var o = {}; Object.defineProperty(o, 'prop', { configurable: true, value: 'val' }); delete o.prop; // true o.prop; // undefined But it doesn't work in the following case, at least on Firefox and Chrome: var form = document.createElement('form'), input = document.createElement('input'); form.appendChild(input); var elems = form.elements; Object.getOwnPropertyDescriptor(form, 0) .configurable; // true <────────────────────── !!! delete elems[0]; // false │ elems[0]; // input │ (function(){ 'use strict'; // V delete elems[0]; // TypeError: property 0

Clarity on the difference between “LexicalEnvironment” and “VariableEnvironment” in ECMAScript/JavaScript

岁酱吖の 提交于 2019-11-29 04:35:58
Could someone clarify what the difference is between these two, as they exist in the Execution context? It's hard for me to read the ECMA 262 v 5 specification and clearly see the difference. Thank You, Bergi Both are components (of the same type) of Execution Contexts, but they serve distinct purposes ( from the spec ): LexicalEnvironment Identifies the Lexical Environment used to resolve identifier references made by code within this execution context. VariableEnvironment Identifies the Lexical Environment whose environment record holds bindings created by VariableStatements and

Why JSON allows only string to be a key?

你。 提交于 2019-11-29 03:55:09
Why does JSON only allow a string to be a key of a pair? Why not other types such as null , number , bool , object , array ? Considering JSON is tightly related with JavaScript, could I conclude the reason from JavaScript specification (ECMA-262)? I'm totally a newbie to JavaScript, could you help me to point it out. The JSON format is deliberately based on a subset of JavaScript object literal syntax and array literal syntax, and JavaScript objects can only have strings as keys - thus JSON keys are strings too. (OK, you can sort of use numbers as JavaScript object keys, but really they get

What is the scope of a function in Javascript/ECMAScript?

泄露秘密 提交于 2019-11-28 19:21:44
问题 Today I had a discussion with a colleague about nested functions in Javascript: function a() { function b() { alert('boo') } var c = 'Bound to local call object.' d = 'Bound to global object.' } In this example, trials point out that b is not reachable outside the body of a, much like c is. However, d is - after executing a(). Looking for the exact definition of this behaviour in the ECMAScript v.3 standard , I didn't find the exact wording I was looking for; what Sec.13 p.71 does not say, is

Is there any way to check if strict mode is enforced?

≯℡__Kan透↙ 提交于 2019-11-28 16:16:41
问题 Is there anyway to check if strict mode 'use strict' is enforced , and we want to execute different code for strict mode and other code for non-strict mode. Looking for function like isStrictMode();//boolean 回答1: The fact that this inside a function called in the global context will not point to the global object can be used to detect strict mode: var isStrict = (function() { return !this; })(); Demo: > echo '"use strict"; var isStrict = (function() { return !this; })(); console.log(isStrict)