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

Popular posts from this blog

How do you change vbulletin's home page to the forums instead of the default (CMS or Activity Stream)? -

c++ - Troubles when compiling phash program -