ecmascript-5

How will Ecma-262 (EcmaScript 5) help you?

EcmaScript Fifth Edition, or Ecma-262, has been announced and contains some changes to the language. What features in the new version are going to help you write better code? ...

Which JavaScript OOP design pattern will most take advantage of (new) ECMAScript 5 features?

ECMAScript 5 is in final draft now, and includes new features relating to objects and prototypes. While hunting around SO and Google for OOP design patterns, I found that there were quite a few different ways of "doing OOP" (however you might define OOP, from trying to emulate classical OOP to simply trying to cut down namespace polluti...

Which (javascript) environments support ECMAscript 5 strict mode? (aka "use strict")

ECMAScript 5 is in its final draft as I write this; It is due to include a strict mode which will prevent you from assigning to the global object, using eval, and other restrictions. (John Resig's Article is a good introduction.) This magical sanity-saving mode is triggered by including the string "use strict" at the top of your file (o...

Is there a library which implements new Javascript/Ecmascript 5 methods for older versions?

Although Ecmascript 5 introduces some completely new features, it also adds some new methods (bind, trim, map, etc.) which should be perfectly possible to implement (albeit slower) in current versions. Does a library exist which implements these backwards compatible features (and no more, excluding Prototype et. al.) ...

Possible typos in ECMAScript 5 specification?

Does anybody know why, at the end of section 7.6 of the ECMA-262, 5th Edition specification, the nonterminals UnicodeLetter, UnicodeCombiningMark, UnicodeDigit, UnicodeconnectorPunctuation, and UnicodeEscapeSequence are not followed by two colons? From section 5.1.6: Nonterminal symbols are shown in italic type. The definition of ...

Why does EcmaScript 5 strict mode go to such great lengths to restrict the identifier `eval`

According to the spec (Annex C), strict-mode code can't do pretty much anything that might assign any identifier with the name eval. I can understand that one might want to restrict use of the actual eval function, but I don't see what purpose is served by restricting use of the name? ...

EcmaScript 5 browser implementation

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. ...

In ECMAScript5, what's the scope of "use strict"?

What scope does the strict mode pragma have in ECMAScript5? "use strict"; I'd like to do this (mainly because JSLint doesn't complain about it): "use strict"; (function () { // my stuff here... }()); But I'm not sure if that would break other code or not. I know that I can do this, which will scope the pragma to the function... ...

How to run javascript in ECMA 5th edition strict mode?

Possible Duplicate: Javascript: use strict Is there any way to know how and which browsers support it? ...

Why doesn't an octal literal as a string cast to a number?

In JavaScript, why does an octal number string cast as a decimal number? I can cast a hex literal string using Number() or +, why not an octal? For instance: 1000 === +"1000" // -> true 0xFF === +"0xFF" // -> true 0100 === +"0100" // -> false - +"0100" gives 100, not 64 I know I can parse with parseInt("0100" [, 8]), but I'd like to ...

What modernizer scripts exist for the new ECMAScript 5 functions?

ECMAScript 5 has quite a few nice additions. John Resig has a good overview here. Here is a good ECMAScript 5 compatibility table. A lot of this stuff can be "faked" for browsers that don't support these functions yet. Do you know of any scripts that can do this? I'm particularly interested in Object.create. For example, Douglas Crock...

How can I define a default getter and setter using ECMAScript 5?

How can I specify a default getter for a prototype? With default getter I mean a function that is called if obj.undefinedProperty123 is called. I tried Object.prototype.get = function(property) {..} but this is not called in this case. ...

JavaScript - Encapsulation ?

A long time ago, I saw someone encapsulate their entire javascript block with code something like the code below: <html> <body> ... <script> (function(){ ... })(this); </script> </body> </html> Questions: Is the code above correct? What benefit is there to encapsulating the entire javascript block like denoted above? ...

Object.defineProperty in ES5?

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. ...

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

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 th...