Functions in JavaScript

 A JavaScript function is a block of organized, reusable code that is defined to perform a single, relation action. A function is executed when someone calls the function with the name.Note – I am sharing all my JavaScript Developer Certification study notes here. Please provide your feedback if you see anything wrong or missing. Appreciate your help.In JavaScript, functions are treated as first-class because they are treated as values. The example of treating function as values are – We can assign a function to a variableWe can store functions in an arrayA function can be passed to another function as an argumentA function can be assigned to a property of an object.You can find the video where I have explained everything here. I have also included the video at the end of this post.Defining a functionA function is defined with the keyword function followed by the name of the function and then the optional functional parameters. Defining a function will not do anything unless you invoke the function. Below code shows a basic example of defining a function and then invoking the same function.//Defining the functionfunction sayHello(name) { console.log(“Hello, ” + name + ” to the world of JavaScript”);}//invoking the functionsayHello(“Shane James”);Function returning valueBy default, all functions return value, but in the above example, the return value is undefined. We can define the return and then store the return value in some variable like...

Read More