Hi. I installed node.js 4.2.1(argon).
I noticed new key 'let' of ES6. 
(https://developer.mozilla.org/ko/docs/Web/JavaScript/Reference/Statements/let)

I understood that let use lower memory than 'var'. because let has block 
scope, but 'var' has function scope.

So I tested memory usage of var and let.

But test result refer to 'var' uses lower memory than 'let'.
differences of rss, heapTotal, heapUsed value of 'let' is bigger than 'var'.

do I misunderstand 'let'? 

Sorry for my english writting, I am english newbie. 

below is my test code.

let.js
'use strict'
let pre = process.memoryUsage();

console.log('pre', pre);

function f() {
    let obj = {x: 12};
    return obj.x;
}

function test() {
  for (let i =0;i<10000000000;i++) {
    f();
  }
}
test();

let post = process.memoryUsage();
console.log('post', post);

var.js
'use strict';

var pre = process.memoryUsage();
console.log('pre', pre);
function f() {
  var obj = {x: 12};
  return obj.x;
}
function test() {
  for (var i =0;i<10000000000;i++) {
    f();
  }
}
test();

var post = process.memoryUsage();
console.log('post', post);


-- 
Job board: http://jobs.nodejs.org/
New group rules: 
https://gist.github.com/othiym23/9886289#file-moderation-policy-md
Old group rules: 
https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
--- 
You received this message because you are subscribed to the Google Groups 
"nodejs" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to nodejs+unsubscr...@googlegroups.com.
To post to this group, send email to nodejs@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/nodejs/2b96af14-79b1-4b92-8300-71c80426a021%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to