ecmascript-2016

Difference between ECMAScript 2016 exponentiation operator and Math.pow()

天涯浪子 提交于 2020-12-25 01:38:55
问题 What is the benefit to using the ECMAScript 2016 exponentiation operator over the current Math.pow() ? In other words, besides reducing key strokes, what is the difference between Math.pow(2, 2) => 4 and 2 ** 2 => 4 回答1: None. As you can read in the ES7 spec, both Math.pow and the ** exponentation operator cast their arguments/operands to numbers and use the very same algorithm to determine the result. Addendum : this changed with the introduction of the BigInt type in ES2020, whose values

Difference between ECMAScript 2016 exponentiation operator and Math.pow()

≯℡__Kan透↙ 提交于 2020-12-25 01:38:33
问题 What is the benefit to using the ECMAScript 2016 exponentiation operator over the current Math.pow() ? In other words, besides reducing key strokes, what is the difference between Math.pow(2, 2) => 4 and 2 ** 2 => 4 回答1: None. As you can read in the ES7 spec, both Math.pow and the ** exponentation operator cast their arguments/operands to numbers and use the very same algorithm to determine the result. Addendum : this changed with the introduction of the BigInt type in ES2020, whose values

JavaScript exponentiation unary operator design decision

一笑奈何 提交于 2019-12-31 00:40:44
问题 So I was fooling around with the new exponentiation operator and I discovered you cannot put a unary operator immediately before the base number. let result = -2 ** 2; // syntax error let result = -(2 ** 2); // -4 let x = 3; let result = --x ** 2; // 4 From the documentation on MDN: In JavaScript, it is impossible to write an ambiguous exponentiation expression, i.e. you cannot put a unary operator ( + / - / ~ / ! / delete / void / typeof ) immediately before the base number. In most

Which Typescript Features are Not Implemented in ES6? [closed]

ぃ、小莉子 提交于 2019-12-20 10:53:49
问题 Closed . This question needs to be more focused. It is not currently accepting answers. Want to improve this question? Update the question so it focuses on one problem only by editing this post. Closed 4 years ago . Apart from the obvious type system, I have read that there are features in TypeScript that are not available in ES6. The article did not mention what these features were or why they should be avoided. I am already aware that TypeScript implements ES7 async/await syntax and this

What makes ES6 so special?

眉间皱痕 提交于 2019-12-13 07:46:51
问题 So I've only recently started to dive head first into web development. One thing I gathered very quickly was that ES5 = old, and ES6 = shiny and new. I figured ES6 was the latest and greatest ES had to offer. But I just found out that ES6 is 3 standards behind, and that some of the features I've been using and loving aren't even a part of it—they came in later specifications. So why does everything I read make it seem like there's just ES5 and ES6? 回答1: ES6 (later rebranded as ES2015 ) simply

Does Angular 5 polyfill async / await for IE11

橙三吉。 提交于 2019-12-05 00:00:50
问题 We develop a software which needs to be supported by IE11. As multiple sources state, IE11 does not support async/await: https://caniuse.com/#feat=async-functions http://kangax.github.io/compat-table/es2016plus/ as well as several blog-articles. We did now write a simple Angular 5 project which uses async/await and it is working fine in IE11. Can we safely assume that Angular uses some kind of polyfill to add support for this in IE11? I cannot find any source stating that Angular adds support

ES2015/2016 way of 'typeof varName === 'undefined`?

泪湿孤枕 提交于 2019-12-03 06:28:11
问题 I'm wallowing in ES2015+ luxury with a few projects right now and am wondering whether I can get rid of the much hated crutch to check for undefined in the new wonderland. Is there a shorter but still exact way to typeof varName === 'undefined' in ES2015+ already? Of course I could use default parameters but this also feels like an unnecessary assignment. function coolFn(a = null){ if (a===null) console.log("no a supplied"); } 回答1: Just check for varName === undefined . In older browsers it

Which Typescript Features are Not Implemented in ES6? [closed]

百般思念 提交于 2019-12-03 00:39:58
Closed . This question needs to be more focused. It is not currently accepting answers. Learn more . Want to improve this question? Update the question so it focuses on one problem only by editing this post . Apart from the obvious type system, I have read that there are features in TypeScript that are not available in ES6. The article did not mention what these features were or why they should be avoided. I am already aware that TypeScript implements ES7 async/await syntax and this post ( Which ES6 Features are Implemented in Typescript ) gives us the inverse relationship. New features that

ES2015/2016 way of 'typeof varName === 'undefined`?

ぐ巨炮叔叔 提交于 2019-12-02 21:01:52
I'm wallowing in ES2015+ luxury with a few projects right now and am wondering whether I can get rid of the much hated crutch to check for undefined in the new wonderland. Is there a shorter but still exact way to typeof varName === 'undefined' in ES2015+ already? Of course I could use default parameters but this also feels like an unnecessary assignment. function coolFn(a = null){ if (a===null) console.log("no a supplied"); } Just check for varName === undefined . In older browsers it was possible to assign an alternate value to the global undefined variable causing that test to fail, but in

JavaScript exponentiation unary operator design decision

人走茶凉 提交于 2019-12-01 19:44:40
So I was fooling around with the new exponentiation operator and I discovered you cannot put a unary operator immediately before the base number. let result = -2 ** 2; // syntax error let result = -(2 ** 2); // -4 let x = 3; let result = --x ** 2; // 4 From the documentation on MDN : In JavaScript, it is impossible to write an ambiguous exponentiation expression, i.e. you cannot put a unary operator ( + / - / ~ / ! / delete / void / typeof ) immediately before the base number. In most languages like PHP and Python and others that have an exponentiation operator (typically ^ or ** ), the