JavaScript Interview Episode 1 - Difference between a Function Declaration and Function Expression

Publié le: 26 avril 2024
sur la chaîne: NomadCoder
357
13

There are three ways a JavaScript function can be created. They are as follows:

1. Function declaration
2. Function expression
3. Arrow function

When you create a function as a declaration or statement, it gets hoisted at the top of the execution context and can be used before it is made. Example below:

console.log(Foo());
function Foo(){

return "Returned from function Foo";
}


When you create a function as an expression, it does not get hoisted at the top of the execution context and cannot be used before it is made. Example below:

console.log(Koo); // error
var Koo = function Koo(){
return "Return from function Koo";
}

Watch the full video for explanation. Also please like and subscribe the channel.


Sur cette page du site, vous pouvez voir la vidéo en ligne JavaScript Interview Episode 1 - Difference between a Function Declaration and Function Expression durée heure minute seconde en bonne qualité , qui a été Téléchargé par l'utilisateur NomadCoder 26 avril 2024, Partagez le lien avec vos amis et connaissances, sur youtube cette vidéo a déjà été regardée 357 fois et il a aimé 13 téléspectateurs. Bon visionnage!