Why this code works? (bizarre syntax in javascript) -


this question has answer here:

i found line of code works:

 for(let in [0,1,2]) {console.log('wtfjs');}

but not these:

 for(var in [0,1,2]) {console.log('js');}  for(const in [0,1,2]) {console.log('js');}

(try on chrome, firefox edge!)

i'm totally puzzled it.

found one

for(let of [0,1,2]) {console.log(let);} 

why not work?

it appears let implies variable name 'let' var , const not imply name. need variable or const name in ones don't work. this:

 for(var x in [0,1,2]) {console.log('js');}  for(const y in [0,1,2]) {console.log('js');} 

Comments

Popular posts from this blog

PHP and MySQL WP -

android - InAppBilling registering BroadcastReceiver in AndroidManifest -

go - golang pprof for c library code -