Hi! An English newbie, here, too ;-)
This is not a direct answer to your question, but I did a quick test (with only 10_000_000 cycles haha you have plenty of time ;-) let.js: change the let to var in the for, and the time is near to var.js version let.js: change the let to var in the f funcion, and the time is near to original let.js version First conclusion: the let in the for has more cost than the let in f function, because it involves a local var to the for, while let in f function is totally equivalent to var Angel "Java" Lopez @ajlopez On Sun, Dec 6, 2015 at 10:57 AM, jeongsik woo <realjays1...@gmail.com> wrote: > 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 > <https://groups.google.com/d/msgid/nodejs/2b96af14-79b1-4b92-8300-71c80426a021%40googlegroups.com?utm_medium=email&utm_source=footer> > . > For more options, visit https://groups.google.com/d/optout. > -- 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/CAMs%2BDqLn2r3%2BXxAwy4FfjHroZkPC8y2G2OTjTV3fJyuw3%3DGBKw%40mail.gmail.com. For more options, visit https://groups.google.com/d/optout.