1//checks if is object, null val returns false
2function isObject(val) {
3 if (val === null) { return false;}
4 return ( (typeof val === 'function') || (typeof val === 'object') );
5}
6var person = {"name":"Boby Snark"};
7isObject(person);//true
1function Phone(serial, price, color){
2 this.serial = serial;
3 this.price = price;
4 this.color = color;
5}
6
7let phone1 = new Phone('abc1', 200, 'red');
8let phone2 = new Phone('abc2', 400, 'green');
9
10//instanceof
11console.log(phone1 instanceof Phone) // true
12
13//constructor
14console.log(phone1.constructor === Phone) //true