Monday, January 29, 2018

I saw Jeff Strauss speak on ES2016, ES2017, and what is in the pipe for the future of JavaScript at the St. Louis .NET User Group tonight.

It has been a long day, but let me see if I can touch on the high level of what I learned. Alright, ES6 in 2015 was the first major update to ECMAScript since 2009 and it had some interesting things in it like the promise API and the fat arrow operator for better handling lexical this and also something called "destructoring" which would define the k and the v variables for key value pairs in:

for (const [k, v] of Object.entries(family)){

 
 

Object.entries (manhandling the "family" variable here, which would be a JSON object) is of ES2017 however and will give us an array of arrays wherein each of the nested arrays are two items long and the first of the two items is the string name of a key on the object and the second item is the value itself. There is a concept now in ECMAScript called iterable which is akin to IEnumerable in C# insofar as that a thing that is iterable may be iterated over. There are new iterable goodies like maps and sets but of course an object is not iterable. This gets around that. There is also a more simplistic Object.values which just gives an array of the values in ES2017 and as much and Object.entries are follow-ups to Object.keys which already existed which gives an array of strings with just the names of the keys. The async and await keywords of C# are now right there in ECMAScript too as of ES2017.

async function awaitCalls(){
   const a = await loadData();
   const b = await loadOverData(a);
   const c = await processTheData(b);
   const d = await saveData(c);
   console.log(d);
}

 
 

Alright this is a little bit better than chaining .Done four times over as the a variable can be used downstream of the setup of the b variable if you like and the whole thing may be wrapped in a try/catch. Promise.all which is kinda like .WhenAll in C# may now be sidestepped for just handing two things into a function with the await keyword leading both actors. So that leaves ES2016 between the current version and the one two back to explain. What was new in it? Only two things. One was a double asterisk operator for raising numbers to a certain power. The other was a .includes for arrays to see if an array contains something in lieu of using an .indexOf is not strictly equals comparison against -1 which will always return false if NaN is somewhere in the array in a buggy manner. Coming the future? A spread operator like that of TypeScript and hopefully private and public variables! This talk was hosted at World Wide Technology, Inc. The employee who let me in the door said that the company was akin to a "one stop shop" for IT needs. They build LANs and they also do custom application development. It sounded to me like a modern Network Logistic, Inc. with the "one stop shop" tag line and what not. There was a lightning talk before the main talk by a John Baluka on TestStack.net, an open source project, and to some extent its not-for-free rivals Ranorex and Coded UI, which may be used in tandem with Selenium testing to provide test data in a better way akin to that of an ORM or may be used to test desktop stuff for .NET be it WinForms or WPF stuff. In the latter case, TestStack.net in particular has something akin to the Google Chrome Developer Tools or the F12 tools of IE called "UI Automation Verify" which allows one to inspect the elements in the UI and manipulate them. Again, that's for desktop app stuff. I've moved to St. Louis, Missouri everyone!

No comments:

Post a Comment