[JS] – How to implement functions ?

Passing values :

var myFunc = function(x) {
  return x * x;
};

console.log(myfunc(3));
// → 9

Without passing values :

var myFunc = function() {
  console.log("My func was called")
};

console.log(myfunc());
// → "My func was called"

 

Leave a comment