Monday, October 31, 2016

JavaScript: Function vs Function Object

// Constructor function
var Fn = function (){

}

// Create an object instance of a function
var fn = new Fn();

console.log('Fn type is: ' + typeof Fn);
console.log('fn type is: ' + typeof fn);
console.log('fn is an instance of Fn: ' + (fn instanceof Fn));

Output:
Fn type is: function
fn type is: object
fn is an instance of Fn: true