The problem of the scope of formal parameters of js function

(function e(num){
        var num;
        console.log(num);
        num = 10;
    }(100))

Why does it print out to be 100? my understanding is that var num; redefines the num variable. It should be undefined, asking the boss for advice.

Mar.11,2021

existing will not be redeclared, ignoring var .


your way of writing will define num = 100at the beginning, so num has a value


is equivalent to defining num twice in the function body, and the second time without assignment will have no effect.


declaration statement only has declaration function, and undefined

will not be assigned automatically.
MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1b38756-2c0f9.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1b38756-2c0f9.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?