2nd Day
Q. Hey guys ,What is hoisting in JavaScript?.
A . In JavaScript, first become variable declaration and then initialization ,
Before initialization couldn't said about the datatype.
If we will try to know through the JavaScript interpreter it will show undefined.
so this concept is known as Hoisting.
For Example : Input
Explanation:
In above example, 1st alert function will show as an input undefined .Because 1st alert function only hoist the declaration of the variable it will not take initialized value so due to this reason 1st alert function will give as an output undefined. And 2nd alert function will give as an output value of x.
Output:
Output:
Reference error and undefined are two different things.
Thank you...
ليست هناك تعليقات:
إرسال تعليق