What is javascript hoisting?



What is javascript hoisting?..

Answer / Prashant Kumar Srivastava

"JavaScript hoisting is a mechanism where variable and function declarations are moved to the top of their respective scopes during the compilation phase. This means that declared variables and functions are accessible before they are actually defined in your code.nFor example:n```javascriptnconsole.log(hello); // Output: undefinednvar hello = 'World';n``` In this example, the variable `hello` is hoisted to the top of its scope, so it appears as if the assignment happens before the call to `console.log()`, resulting in the output of `undefined`."n

Is This Answer Correct ?    0 Yes 0 No

Post New Answer

More JavaScript Interview Questions

Can we learn javascript without knowing java?

1 Answers  


Why extending array is bad idea?

1 Answers  


How can javascript codes be hidden from old browsers that don't support javascript?

1 Answers  


What are the application of javascript?

1 Answers  


What is a javascript code?

1 Answers  


Why global variables are bad javascript?

1 Answers  


What is the statement to enable strict mode in javascript quiz?

1 Answers  


What is a boolean in javascript?

1 Answers  


What are the types used in javascript?

1 Answers  


What makes a relation a function?

1 Answers  


How do I get javascript?

1 Answers  


What is the Difference between HTML and DHTML

15 Answers   TCS,


Categories