Notes of Maks Nemisj

Experiments with JavaScript

JavaScript execution

Do you know what would be the result of the following code executed in node.js without babel and any transpiling?

const s = 'Maks';
for (var i = 0;i < s.length; i++) {
  const ch = s.charAt(i);
  console.log('ch:' + ch);
}

example.js

Do you know the result ? Think good …

 

 

 

And one more time

 

 

 

Well, it appears that it depends on the version of the node.js ( and guess what ) on use strict directive.
Without use strict result varies:

node: v4.4.7  - MMMM
node: v5.12.0 - MMMM
node: v6.3.1  - Maks

Though, if you would prepend use strict at the top of the file and would run it all node versions would return the same result:

node: v4.4.7  - Maks
node: v5.12.0 - Maks
node: v6.3.1  - Maks

I thought that the javascript differences were only in the browsers, but appears it’s not.

https://gist.github.com/nemisj/d3250dd8e1dbe1a1cbaa3ba8481c38ce

, ,

Leave a Reply

Your email address will not be published. Required fields are marked *