ecma262

Can I disable ECMAscript strict mode for specific functions?

牧云@^-^@ 提交于 2019-11-27 06:56:52
I don't find anything about my question here on MDC or the ECMAscript specifications. Probably somebody knows a more 'hacky' way to solve this. I'm calling "use strict" on every javascript file in my environment. All my files start like this (function(win, doc, undef) { "use strict"; // code & functions }(window, window.document)); Now, I have a custom function which handles errors. That functions uses the .caller property to provide a context stack trace . Looks like this: var chain = (function() { var _parent = _error, _ret = ''; while( _parent.caller ) { _ret += ' -> ' + _parent.caller.name

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

时光毁灭记忆、已成空白 提交于 2019-11-27 06:50:41
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 supposed to be valid assignment expressions? * From my humble understanding, this would make much more

Javascript maximum size for types?

一个人想着一个人 提交于 2019-11-27 05:25:01
Looking into javascript types I'm trying to find out what the maximum storage size for some data types are. For instance, I set up a quick recursive algo to increase var size till the browser crashes, which ends up being somewhere close to 128mb (or maybe it's 256) for strings on my existing version of chrome. I've been doing it the painful way because I couldn't find any specs on this, but constant browser crashes make this a painful trial (try catch seems useless for some reason with this particular issue). I'm looking for information about maximum storage size for the other types also

Javascript IN operator compatibility

谁说胖子不能爱 提交于 2019-11-27 05:13:51
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 } 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. You should err on the side of caution when using it to check event support. All implementations except older

Why does “dtoa.c” contain so much code?

微笑、不失礼 提交于 2019-11-27 04:22:43
问题 I'll be the first to admit that my overall knowledge of low level programming is a bit sparse. I understand many of the core concepts but I do not use them on a regular basis. That being said I was absolutely astounded at how much code was needed for dtoa.c. For the past couple months I have been working on an ECMAScript implementation in C# and I've been slowing filling in the holes in my engine. Last night I started working on Number.prototype.toString which is described in section 15.7.4.2

Math.pow with negative numbers and non-integer powers

醉酒当歌 提交于 2019-11-27 03:29:26
问题 The ECMAScript specification for Math.pow has the following peculiar rule: If x < 0 and x is finite and y is finite and y is not an integer, the result is NaN. (http://es5.github.com/#x15.8.2.13) As a result Math.pow(-8, 1 / 3) gives NaN rather than -2 What is the reason for this rule? Is there some sort of broader computer science or IEEEish reason for this rule, or is it just a choice TC39/Eich made once upon a time? Update Thanks to Amadan's exchanges with me, I think I understand the

Object.defineProperty in ES5?

末鹿安然 提交于 2019-11-26 23:01:39
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. 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-based implementations there is no way to change the property attributes. The Object.defineProperty method as

Relation between [[Prototype]] and prototype in JavaScript

白昼怎懂夜的黑 提交于 2019-11-26 22:32:56
问题 From http://www.jibbering.com/faq/faq_notes/closures.html : Note: ECMAScript defines an internal [[prototype]] property of the internal Object type. This property is not directly accessible with scripts, but it is the chain of objects referred to with the internal [[prototype]] property that is used in property accessor resolution; the object's prototype chain. A public prototype property exists to allow the assignment, definition and manipulation of prototypes in association with the

Why was ECMAScript 4th edition completely scrapped?

做~自己de王妃 提交于 2019-11-26 16:53:02
问题 I've been looking for some information regarding the scrapped ECMAScript 4th Edition without much success, even on SO. I know Mozilla's JavaScript 1.7 implemented many (all?) of the new features offered in 4th Edition and I thought I remembered a good John Resig post on it but I can't seem to find it on his blog now. In particularly, I want to know why it was completely scrapped in favour of ECMA-262 5th Edition and why it wasn't just improved upon. Some of the features are pretty cool, like

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

青春壹個敷衍的年華 提交于 2019-11-26 16:06:26
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 . Infinity and NaN aren't keywords or anything special, they are just properties on the global object (as is undefined ) and as such