1let myObject = {
2 firstname: 'harry',
3 lastname: 'potter'
4}
5//check the typeof if, boolean, object, string etc...
6console.log(typeof myObject);
7if(typeof myObject === 'object') {
8 console.log('this is object');
9}
1function IsJsonString(str) {
2 try {
3 JSON.parse(str);
4 } catch (e) {
5 return false;
6 }
7 return true;
8}
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