HOISTING Variables” and “ function” declarations are moved to the top of their scope before code execution. Variables are hosted and not their values Only the normal function will be hoisted not the anonymous,IIFE and Arrow Function will be hoisted Properties are not hoisted PROPERTY Any variable declared globally become property of window variable declared without keyword variable declared with keyword var except function scope var console . log ( a ) // Error a not defined console . log ( a ); // undefined --> var a is hoisted not value var a = 20 ; console . log ( a , b ) // Error --->property b can't hoist var a = 20 ; b = 40 ; var a = add ( 2 , 5 ) // Error console . log ( a ) var a = add ( 2 , 5 ) // 7 function add hoist console . ...
Comments
Post a Comment