Javascript Function Definition Declaration vs Function Literal

Description

Javascript Function Definition Declaration vs Function Literal


// Declaring a function using the function statement
function writeln(message) {
    // First we check if the argument exists
    if (message)    
        console.log(message);    /*from ww w.  j a v a 2s.co m*/
}
writeln("Hello world!");   

// Declaring a function using the function literal notation (an "anonymous" function)
let writeln1 = function(message) {
    // First we check if the argument exists
    if (message)    
        console.log(message);
}
writeln1("Hello world!"); 



PreviousNext

Related