Sunday, May 26, 2019

I saw Jennifer Estrada speak on ECMAScript 6 JavaScript at the Norwegian Developers Conference whilst very pregnant with her daughter.

The modern day company Accenture is the Anderson Consulting arm of Enron rebranded. Did you know that? I guess I'm already off topic. JScript (the JavaScript files inside Visual Studio) and ActionScript are ECMAScript like what we think of as JavaScript which is also really ECMAScript. ClojureScript compiles Clojure to JavaScript. A lot of ES6 features are available in TypeScript. const uses "block scope" like let in ES6 as is the case in TypeScript. Declaring objects with const really only declares an immutable binding, and you can change the properties on a const object. const variables must be given a value the moment they are assigned and that breaks with other languages. Arrow functions simplify scope. You don't have to have .bind(this) and instead the guts are "lexically bound" and inherit the context of this from the code that uses the arrow function. Again, this is like TypeScript, only in JavaScript. The string interpolation of TypeScript has a sister in what are known as template strings in ECMAScript 6. It is the same syntax with backticks, curly braces, and dollar signs. You may use apostrophes mundanely inside of the backticks like they are just another character. You may have a default parameter in a function like so:

function multiply(a, b=2) {
   return a * b;
);

 
 

I confirmed that this is TypeScript compiler safe in the event of just calling the function with one variable during the talk in the occurrence of a mishmash between this code and some TypeScript. Without the =2 that act would be impossible in TypeScript as the compiler would freak out, and freak out well upstream of the return statement merely erroring out when multiplication against undefined wasn't feasible. Obviously, in TypeScript itself having a question mark following the variable name (then followed by a colon and furthermore followed by a type) is another way to have an optional actor that is TS safe. Another attendee pointed that out to me as I left the talk which is what everyone says to me when I point my finger at the one way TypeScript is not a superset of JavaScript. There is an Airbnb Linter. You may have nested deconstruction in ECMAScript 6. If something is thenable you may use the .then on it. Anything declared without async is inherently using the promise API so it has a .then to call.

No comments:

Post a Comment