cover-img

Hoisting

Use Function Before Declaration

31 October, 2022

0

0

0

Contributors

Javascript pre-assumes that the declaration is on the top of current scope.
Let's say if we have defined a function in the bottom of our scope of script or function, even javascript interprter runs line by line , everyone can use this function before declaration . But keep in mind we will declare it later after using it , otherwise it will never work
Output
This will print hello , no matter you decalre it before calling or after calling.
var
Output
In short , we can say Hoisting is a behaviour which moves the declarations on the top while interpreting its code.

Arrow functions are not hoisted.

Above code will return ReferenceError
Do it yourself with var keyword and arrow functions.
Also comment down if I have committed any mistake. Let's connect on my socials -- Always Open for new opportunities , if I am free :P

0

0

0

Saurav
Looking for Full Stack Development Opportunity | MERN, React Native, Kotlin, C++

More Articles

Showwcase is a professional tech network with over 0 users from over 150 countries. We assist tech professionals in showcasing their unique skills through dedicated profiles and connect them with top global companies for career opportunities.

© Copyright 2025. Showcase Creators Inc. All rights reserved.