Why are Octal numeric literals not allowed in strict mode (and what is the workaround?)

Octal literals are not allowed because disallowing them discourages programmers from using leading zeros as padding in a script. For example, look at the following snippet: var eight = 0008, nine = 00009, ten = 000010, eleven = 011; console.log(eight, nine, ten, eleven); Seems harmless enough, right? We programmers with OCD just want to align … Read more

What Internal Property In ECMAScript is defined for?

Internal properties define the behavior of code as it executes but are not accessible via code. ECMAScript defines many internal properties for objects in JavaScript. Internal properties are indicated by double-square-bracket notation. For example, JavaScript function is an object and it has [[call]] property. [[call]] property is unique to function. Another internal property example is … Read more

Object.defineProperty in ES5?

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 @Raynos mentioned, works on IE8, but partially, it can … Read more

Regex only capturing last instance of capture group in match

Regardless of the problem, ActionScript and JavaScript should always yield the same results, as they both implement ECMAScript (or a superset thereof, but for regular expressions they should not disagree). But yes, this will be happening in any language (or rather any regex flavor). The reason is that you are repeating the capturing group. Let’s … Read more

What object javascript function is bound to (what is its “this”)?

Partial Application You can do partial application: // This lets us call the slice method as a function // on an array-like object. var slice = Function.prototype.call.bind(Array.prototype.slice); function partial(f/*, …args */) { if (typeof f != ‘function’) throw new TypeError(‘Function expected’); var args = slice(arguments, 1); return function(/* …moreArgs */) { return f.apply(this, args.concat(slice(arguments))); }; … Read more

Can I disable ECMAscript strict mode for specific functions?

No, you can’t disable strict mode per function. It’s important to understand that strict mode works lexically; meaning — it affects function declaration, not execution. Any function declared within strict code becomes a strict function itself. But not any function called from within strict code is necessarily strict: (function(sloppy) { “use strict”; function strict() { … Read more