Questions tagged [ecmascript-5]

ECMAScript is the name of the Ecma International Standard 262. It is based on the scripting language JavaScript which was delivered by Netscape to Ecma for standardization. The 5th Edition is an update of the 3rd edition specification after the cancellation of the 4th edition. It adds new features including strict mode, getters and setters, a JSON object, and new methods for Object, Array, Date, and Function prototypes.

In 1995 Brendan Eich of Netscape invented a scripting language JavaScript for the Netscape browser. One year later Microsoft developed a compatible dialect of the language, JScript. Lately flash platform implemented its ActionScript language based in the same standard.

Netscape delivered JavaScript to Ecma International for standardization which started the process as EcmaScript in the Ecma-262 Standard in November 1996(5).

ECMAScript-5 is an update of the EMCAScript-262 3rd edition specification after the cancellation of the 4th edition. It adds new features including strict mode, getters and setters, a JSON object, and new methods for Object, Array, Date, and Function prototypes.

Articles covering the new specification in detail are available e.g. on infoq.com and the Opera Dev Channel.

This compatibility table covers the Browser support of EcmaScript 5.

References:

  1. JavaScript Wikipedia Article
  2. EcmaScript Wikipedia Article
  3. Ecma International Website
  4. Ecma-262 Specification
  5. Press Release of Javascript Standardization
  6. EcmaScipt Edition 5 - HTML Version
  7. EcmaScript Edition 3 - PDF Version
1857 questions
76
votes
10 answers

when do you use Object.defineProperty()

I'm wondering when I should use Object.defineProperty to create new properties for an object. I'm aware that I'm able to set things like enumerable: false but when do you need this really? If you just set a property like myObject.myprop =…
Andre Meinhold
  • 5,087
  • 3
  • 21
  • 29
61
votes
2 answers

Object.keys() complexity?

Anyone know the time-complexity of ECMAScript5's Object.keys() in common implementations? Is it O(n) for n keys? Is time proportional to the size of the hash table, assuming a hash implementation? I'm looking for either guarantees by language…
hurrymaplelad
  • 26,645
  • 10
  • 56
  • 76
60
votes
3 answers

Why is delete not allowed in Javascript5 strict mode?

I'm fairly new to javascript. I noticed that apparently when operating in "use strict" mode, you can't delete objects. I'm not a huge fan of deleting things (since, in theory, scope should take care of that anyway), but I wonder what was the…
sircodesalot
  • 11,231
  • 8
  • 50
  • 83
57
votes
1 answer

Indirect eval call in strict mode

I understand about how eval() works in non-strict contexts, however the case of using eval() in strict mode has completely befuddled me. When eval() is called directly in the global scope, variables are kept inside the new eval() scope: 'use…
Qantas 94 Heavy
  • 15,750
  • 31
  • 68
  • 83
55
votes
1 answer

Shim vs. Sham: What is the difference?

What is the difference between a shim an a sham? Is it enough to include es5-shim.min.js and es6-shim.min.js or should I also include es5-sham.min.js and es6-sham.min.js?
garbanzio
  • 846
  • 1
  • 7
  • 10
55
votes
10 answers

What is the difference between 'let' and 'const' ECMAScript 2015 (ES6)?

I'm wondering what is the difference between let and const in ES6. Both of them are block scoped, as the example in the following code: const PI = 3.14; console.log(PI); PI = 3; console.log(PI); const PI = 4; console.log(PI); var PI =…
Hazem Hagrass
  • 9,329
  • 10
  • 32
  • 54
48
votes
7 answers

Getting Error Promise is undefined in IE11

I am converting React code to typescript, target in tsconfig is es5. on running in IE 11 i get an error "Promise is undefined" I know i need to polyfill,but how? I am not using Babel. Following is my Webpack.config var webpack =…
Ankit Raonka
  • 6,429
  • 10
  • 35
  • 54
47
votes
2 answers

Why and how does ([![]]+[][[]])[+!+[]+[+[]]] evaluate to the letter "i"?

While reading this article posted on dzone I found a snippet of JavaScript originally posted on Twitter by Marcus Lagergren. The following code apparently prints the string…
toniedzwiedz
  • 17,895
  • 9
  • 86
  • 131
46
votes
2 answers

gulp babel, exports is not defined

Consider the following example code (and maybe I am doing it wrong?) var FlareCurrency = { }; export {FlareCurrency}; I have the following task: gulp.task("compile:add-new-currency-minified", function(){ return…
TheWebs
  • 12,470
  • 30
  • 107
  • 211
43
votes
4 answers

A function is larger than an array?

A friend of mine discovered some interesting behaviour in some Javascript code, which I decided to investigate further. The comparison (function (x) {return x*x;}) > [1,2,3] returns true in most major browsers (Firefox, Chrome, Opera and Safari)…
evilcandybag
  • 1,942
  • 17
  • 17
43
votes
4 answers

Prototypical OO in JavaScript

TL;DR: Do we need factories/constructors in prototypical OO? Can we make a paradigm switch and drop them completely? The BackStory: I've been toying with doing prototypical OO in JavaScript lately and find that 99% of OO done in JavaScript is…
Raynos
  • 166,823
  • 56
  • 351
  • 396
43
votes
1 answer

`new Object` vs `Object` in the ECMAScript spec

So, I'm looking at the ES5 specification at the definition of what new Object and Object do. To my surprise: new Object describes a whole algorithm of how the object constructor works - treating what happens with different kinds of values.…
Benjamin Gruenbaum
  • 270,886
  • 87
  • 504
  • 504
43
votes
6 answers

CoffeeScript: Getter/Setter in Object Initializers

ECMAScript allows us to define getters or setters as following: [text/javascript] var object = { property: 7, get getable() { return this.property + 1; }, set setable(x) { this.property = x / 2; } }; I can work around if I'm using a…
fridojet
  • 1,276
  • 3
  • 15
  • 29
42
votes
5 answers

Extending Object.prototype JavaScript

I am not asking if this is okay: Object.prototype.method = function(){}; This is deemed evil by pretty much everyone, considering it messes up for(var i in obj). The Real Question Ignoring Incompetent browsers(browsers that don't support…
Lime
  • 13,400
  • 11
  • 56
  • 88
42
votes
4 answers

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…
Stephen Sorensen
  • 11,455
  • 13
  • 33
  • 46