javascript - Strange behaviour whith shadowing -
although shadowing should never used (or obfuscate) because it's confusing, wanted understand it. , got strange thing :
alert(parseint('123'));//here, expected 123 it's 'overshadowed' function parseint(){return 'overshadowed';} alert(parseint('123'));//here it's 'overshadowed'
why first alert
output 'overshadowed' whereas function not modified yet?
p.s : got inspired variable shadowing in javascript
in javascript, declarations implicitly placed @ beginning of scope ("hoisted"), doesn't matter if parseint() definition @ second, last, or first line.
Comments
Post a Comment