Posts

Showing posts with the label es2016

ES2016 feature: exponentiation operator (**)

The exponentiation operator ( ** ) is an ECMAScript proposal by Rick Waldron. It is at stage 4 (finished) and part of ECMAScript 2016 . An infix operator for exponentiation ** is an infix operator for exponentiation: x ** y is produces the same result as Math.pow(x, y) Examples: let squared = 3 ** 2; // 9 let num = 3; num **= 2; console.log(num); // 9 Further reading: Exponentiation Operator (Rick Waldron)

ES2016 feature: Array.prototype.includes

Array.prototype.includes is an ECMAScript proposal by Domenic Denicola and Rick Waldron. It is at stage 4 (finished) and part of ECMAScript 2016 . The Array method includes The Array method includes has the following signature: Array.prototype.includes(value : any) : boolean It returns true if value is an element of its receiver ( this ) and false , otherwise: > ['a', 'b', 'c'].includes('a') true > ['a', 'b', 'c'].includes('d') false includes is similar to indexOf – the following two expressions are mostly equivalent: arr.includes(x) arr.indexOf(x) >= 0 The main difference is that includes() finds NaN , whereas indexOf() doesn’t: > [NaN].includes(NaN) true > [NaN].indexOf(NaN) -1 includes does not distinguish between +0 and -0 ( which is how almost all of JavaScript works ): > [-0].includes(+0) true Typed Arrays will also have a method include...

The final feature set of ECMAScript 2016 (ES7)

Check out my new book (free online): “ Exploring ES2016 and ES2017 ”. We always knew that ECMAScript 2016 (ES2016) would be a small release. It turns out that it will be very small. Read on for a list of its features and an explanation why that is not a problem. The features of ES2016 Any proposals that were at stage 4 on Thursday, 28 January 2016, will be in ES2016 ( source: ECMAScript standard editor Brian Terlson ). That means that ES2016 will contain just two new features (in addition to bug fixes and smaller improvements): Array.prototype.includes (Domenic Denicola, Rick Waldron) Exponentiation Operator (Rick Waldron) The draft of ECMAScript 2016 is online and will be ratified in 2016, probably in June. The new release process works ES2016 being so small demonstrates that the new release process works: New features are only included after they are completely ready and after there were at least two implementations that were sufficiently field-tested. Releases happen much more f...