JavaScript has two ways of defining functions – function expressions (FE) and function declarations (FD)
//function declaration:
function functionName(){
//the code you want to execute
alert("This is a function declaration!")
}
function expression:
var aDifferentFunction = function(){
//the code you want to execute
alert("This is a function expression!")
}
Example Functions: or if you want to get into too much detail http://benalman.com/news/2010/11/immediately-invoked-function-expression/
Array
[1,2,3].toString();
=> "1,2,3"
hash
({name: "Ben}).toString();
=> "[object Object]"
Object
var ObjOne = function(){ this.sayHi = console.log("hi") }; =>undefined
myObj = new ObjOne(); => hi => ObjOne {sayHi: undefined}
myObj.toString(); => "[object Object]"
all objects inherit methods and properties from Object.prototype, but what is it?
callback: when a function gets passed to another function for future use.