1 <!DOCTYPE HTML>2 <HTMLLang= "en">3 <Head>4 <MetaCharSet= "UTF-8">5 <title>Document</title>6 </Head>7 <Body>8 <Script>9 varfoo;Ten //If there is no following line, Foo is a function, if there is a word foo= xx will overwrite function foo () One Foo= 1; A functionfoo () { - Alert (" One") - } the Console.log (typeoffoo); - - </Script> - </Body> + </HTML>
Look at one more:
1 <!DOCTYPE HTML>2 <HTMLLang= "en">3 <Head>4 <MetaCharSet= "UTF-8">5 <title>Document</title>6 </Head>7 <Body>8 <Script>9 varfoo;Ten //If there is no following line, Foo is a function, if there is a word foo= xx will overwrite function foo () One Foo= function() {alert ( A)}; A functionfoo () { - Alert (" One") - } the foo () - - </Script> - </Body> + </HTML>
If Var declares a variable (such as foo), the code is then re-declared, if Foo is not assigned at this time, Foo is a function, such as Foo is assigned value, such as (FOO=XXXX), Foo's function declaration will be overwritten
Analysis of the weights of Var and function