ECMAScript 6 and Proxy

Posted by & filed under Uncategorized.

Being able to intercept a certain operation to an object can be really useful, in particular during a troubleshooting session. With ECMAScript 6, this is possible via its new feature, proxy. Creating a proxy on a particular object allows a predefined handler to get notified when something happens. In the latest draft specification (Rev 15,… Read more »

ECMAScript 6 and Block Scope

Posted by & filed under Uncategorized.

Until today, JavaScript comes with a function-level scope for variables and functions. This quirk often trips beginners who are already familiar with other curly braces language. With ECMAScript 6, the situation will change with the availability of the well-understood block scope. Function-level scope leads to a situation called hoisting. For example, for this code: function… Read more »

ECMAScript 6 and Method Definitions

Posted by & filed under Uncategorized.

Using an object literal populated with some member functions is a common practice in any serious JavaScript applications. This is also useful for all kind of frameworks, in particular to setup object prototypes. The upcoming ECMAScript 6 introduces method definition, a nice shorthand which eliminates the need to use function when using that pattern. Before… Read more »

ECMAScript 6 and Spread Operator

Posted by & filed under Uncategorized.

We have seen how a rest parameter can help the handling of a variable number of function arguments. What about the other way around? Can we turn an array into a series of function arguments? Apparently, ECMAScript 6 defines a new type of operator called the spread operator which does exactly that. Let us review… Read more »

ECMAScript 6 and Rest Parameter

Posted by & filed under Uncategorized.

Handling a function with a variable number of arguments is always tricky in JavaScript. At least, we still have this arguments object which can be used to retrieve all arguments used to invoke a function. With the upcoming ECMAScript 6, no such hack is necessary anymore since we can start using its rest parameter feature…. Read more »

ECMAScript 6 and Object Literal Property Value Shorthand

Posted by & filed under Uncategorized.

Constructing an object using the literal syntax is something that is very familiar to every JavaScript developer, quite likely because this reminds everyone of JSON. While every object property needs to be either a key-value pair or getter/setter, this may change in the near future. Another syntactic sugar in the upcoming ECMAScript 6 is the… Read more »