DEV Community

Cover image for Hoisting in javascript
Chandra Prakash Pal
Chandra Prakash Pal

Posted on

Hoisting in javascript

Hoisting is a features of JavaScript in which we can use any variable or function before initialisation.
for example

console.log(x)
x=10
var x
Enter fullscreen mode Exit fullscreen mode

same as we can do for function as well.

function createFunction(){
return f;
function f(a,b){
return a+b
}
}
const f=createFunction()
console.log(f(3,4)) // 7
Enter fullscreen mode Exit fullscreen mode

Please take reference from here

Top comments (0)