links: JS MOC


Reference Error

it means JavaScript is unable to find identifier. Basically you are trying to access a variable which is not defined yet

orderPizza()
console.log(orderPizza)

In above example orderPizza is not defined so JavaScript throws Reference Error

TypeError

It means you are trying to do something with the value but its not allowed

It usually occurs when you are executing a function, but the reference of the variable is not a function.

orderPizza()
// TypeError
 
var orderPizza = function(){
	console.log('ordering pizza')
}

In above example orderPizza identifier is hoisted and it’s value is undefined when it executes the function, and it gets function reference on line 3.


tags: javascript , error