Function Declaration

Also called a function statement.
This always starts with the keyword "function".
This creates a variable called IsEven in the current scope that holds the function object.
You do not have to put a semicolon at the end.

function IsEven(num) { 
   return num % 2 === 0;

Named Function Decelaration - without Arguments

function doSomething() { 
   alert('my message');


Named Function Decelaration - with Arguments

This function takes 2 parameters
Often called the standard function declaration

function add(x, y) 
   var z = x + y;
   return z;

var sum = add(1,2)

© 2021 Better Solutions Limited. All Rights Reserved. © 2021 Better Solutions Limited TopPrevNext