ecma262

Is there an environment-agnostic way to detect Javascript Host Objects?

拈花ヽ惹草 提交于 2019-12-09 10:10:23
问题 I'm writing a Javascript stacktrace library. The library needs to detect wether a particular object or function was created by the programmer or was there as part of the environment (including built-in objects). Host objects are becoming a bit problematic due to their unpredictable behaviour, so I'm after an environment-agnostic way to determine if a particular object in Javascript is a host object (see ECMAScript 3 - 4.3.8). However, distinguishing host objects from native objects and

Does a real ECMAScript implementation exist, or is it just a spec?

大憨熊 提交于 2019-12-06 06:14:21
问题 I read both of the links below http://en.wikipedia.org/wiki/ECMAScript What is the difference between JavaScript and ECMAScript? My question is, does ECMAScript exist as something I can download and use instead of JavaScript? 回答1: It's just a standard to dictate the implementation of a "javascript" language, it's not something you "download and run". You can write your code against the ECMAScript spec and pretty much expect it to run on all the "javascript" interpreters (or that's the idea

How to make sure ES3 programs will run in an ES5 engine?

旧时模样 提交于 2019-12-06 03:56:13
问题 So ECMAScript 5 introduces some incompatibilities with ECMAScript 3. Example : Many articles have been written stating that this === null || this === undefined is possible in ES5 strict mode : "use strict"; (function () { alert(this); // null }).call(null); But, what the standard really suggests is that ES5 engines also allow this in non-strict mode : 15.3.4.3 ... The thisArg value is passed without modification as the this value. This is a change from Edition 3, where a undefined or null

ANTLR parser hanging at proxy.handshake call

久未见 提交于 2019-12-05 17:17:21
I am attempting to get a basic ECMAScript parser working, and found a complete ANTLR grammar for ECMAScript 3 , which appears to compile ok and produces the appropriate Lexer/Parser/Walker Java files. (Running inside ANTLR IDE plugin for Eclipse 3.5) However, when actually trying to use it with some simple test code (following guide on ANTLR wiki ), it just hangs when trying to create the parser: CharStream MyChars = new ANTLRFileStream(FileName); // FileName is valid ES3Lexer MyLexer = new ES3Lexer(MyChars); CommonTokenStream MyTokens = new CommonTokenStream(MyLexer); MyTokens.setTokenSource

Does a function expression have its own scope/lexical environment

强颜欢笑 提交于 2019-12-05 09:03:31
I'm reading the Execution Context / Lexical Environment section of the ECMA 262 5 specification . It states the following: (emphasis added) A Lexical Environment is a specification type used to define the association of Identifiers to specific variables and functions based upon the lexical nesting structure of ECMAScript code. A Lexical Environment consists of an Environment Record and a possibly null reference to an outer Lexical Environment. Usually a Lexical Environment is associated with some specific syntactic structure of ECMAScript code such as a FunctionDeclaration , a WithStatement,

Why are anonymous function expressions and named function expressions initialized so differently?

◇◆丶佛笑我妖孽 提交于 2019-12-04 08:26:54
I'm looking at section 13 or the ECMAScript specification (v. 5). An anonymous function expression is initialized as follows: Return the result of creating a new Function object as specified in 13.2 with parameters specified by FormalParameterListopt and body specified by FunctionBody. Pass in the LexicalEnvironment of the running execution context as the Scope. Pass in true as the Strict flag if the FunctionExpression is contained in strict code or if its FunctionBody is strict code. this logic is very similar to how a function declaration is initialized. However, notice how different

argumental reference inconsistency in javascript

断了今生、忘了曾经 提交于 2019-12-04 05:56:57
问题 I have recently encountered a nasty issue in JS. Let say we pass a map, an array of objects to a function f. var o=[{a:0}]; function f(a){ for(var i in a){ if (a.hasOwnProperty(i)){ a[i]=null; } } return a; }; var outp=f(o); alert(outp[0]+" === "+o[0]+" : "+(outp[0]===o[0])); // here we expect loose equality, and equality in type, //furthermore it should identically equal as well, and we got right! But, we can not pass total responsibility of an object to a function as argument, same like in

Is '\0' followed by a decimal digit in string allowed in ECMA-262 strict mode?

谁都会走 提交于 2019-12-04 04:21:13
问题 According to the ECMA-262 specification (6th edition) in strict mode in single or double quoted strings after '\' it is possible to have EscapeSequence or LineTerminatorSequence, and EscapeSequence must be one of the following: CharacterEscapeSequence, 0 [lookahead ∉ DecimalDigit], HexEscapeSequence, UnicodeEscapeSequence (see 11.8.4). Does it mean that it is completely incorrect to have any DecimalDigit after '\0' at all? I understand that it is done that way to avoid confusion with

JavaScript: Can ECMAScript 5's Strict Mode (“use strict”) be enabled using single quotes ('use strict')?

删除回忆录丶 提交于 2019-12-03 22:03:35
JavaScript doesn't care if your Strings are double-quoted "double" or single-quoted 'single' . Every example of ECMAScript 5's strict mode has it enabled by "use strict" in double-quotes. Can I do the following (single-quotes): alert(function(){ 'use strict'; return !this; }()); This will return true if Strict mode is enabled, and false if it is not. Felix Kling For you, without using a browser that supports strict mode : A Use Strict Directive is an ExpressionStatement in a Directive Prologue whose StringLiteral is either the exact character sequences "use strict" or 'use strict' . A Use

Is there an i18n (Intl) shim for JavaScript?

别等时光非礼了梦想. 提交于 2019-12-03 12:06:20
问题 I am looking for a shim for the ECMAScript Internationalization API. Does anyone know of such a project? (Even if it's still currently a work-in-progress.) 回答1: Yes, there's a polyfill for ECMA-402 (aka ECMA Internationalization API Specification) available at https://github.com/andyearnshaw/Intl.js. For use in Node.js applications, you can install with NPM: npm install intl It's also available as a Bower component for the front-end: bower install intl There's support for NumberFormat and