Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

javascript check if variable is object

let myObject = {
	firstname: 'harry',
  	lastname: 'potter'
}
//check the typeof if, boolean, object, string etc...
console.log(typeof myObject);
if(typeof myObject === 'object') {
	console.log('this is object');
}
Comment

javascript check if variable is object

//checks if is object, null val returns false
function isObject(val) {
    if (val === null) { return false;}
    return ( (typeof val === 'function') || (typeof val === 'object') );
}
var person = {"name":"Boby Snark"};
isObject(person);//true
Comment

Check if a value is an object in JavaScript

typeof yourVariable === 'object' && yourVariable !== null
Comment

PREVIOUS NEXT
Code Example
Javascript :: add items to a list in a document monoose 
Javascript :: javascript anagram 
Javascript :: lodash remove null from object 
Javascript :: window.scrollto(0 0) not working 
Javascript :: javascript stop execution 
Javascript :: .toJSON() in sequelize 
Javascript :: or operator in javascript 
Javascript :: laravel send http post request json 
Javascript :: javascript select input text on focus 
Javascript :: reverse words javascript 
Javascript :: jquery check if element is hidden 
Javascript :: webpack config minify 
Javascript :: json query online 
Javascript :: fetch api in js 
Javascript :: .net mvc javascript function call link 
Javascript :: flutter print json 
Javascript :: biding multiple class vuejs 
Javascript :: check if isset variable js 
Javascript :: upload preview image jquery 
Javascript :: $q.platform.is.mobile 
Javascript :: javascript get specific timezone 
Javascript :: alpinejs with select 
Javascript :: jquery get duration video tag 
Javascript :: es6 method definition syntax 
Javascript :: get file extension nodejs 
Javascript :: javascript json stringify indented 
Javascript :: nodejs for windows 7 
Javascript :: sort an array of objects in javascript 
Javascript :: wait js 
Javascript :: normalize javascript 
ADD CONTENT
Topic
Content
Source link
Name
9+1 =