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

javascript check if object

typeof yourVariable === 'object' // true if it's an object or if it's NULL.

// if you want to exclude NULL
typeof yourVariable === 'object' && yourVariable !== null
Comment

Check if a value is an object in JavaScript

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

PREVIOUS NEXT
Code Example
Javascript :: how to get dropdown selected value in javascript onchange 
Javascript :: vowel 
Javascript :: ternary operator in angular 
Javascript :: check if url is http or https javascript 
Javascript :: how to install yup in react native 
Javascript :: count number of each element in array javascript 
Javascript :: javascript WeakSet Methods 
Javascript :: flatlist horizontal 
Javascript :: how to create immutable object in javascript 
Javascript :: js events 
Javascript :: javascript parseint string with comma 
Javascript :: how to stop google colab from disconnecting 
Javascript :: javascript array to string 
Javascript :: font awesome react native icons 
Javascript :: javascript for of 
Javascript :: remove special characters from string 
Javascript :: how to remove an element javascript html 
Javascript :: using bootstrap in react 
Javascript :: js number format 
Javascript :: react transition group 
Javascript :: how to remove duplicates in array in javascript 
Javascript :: react add link to button 
Javascript :: character from character code js 
Javascript :: How to lock Orientation for a particular screen in ios in react native 
Javascript :: split decimal value in javascript 
Javascript :: javascript sort numbers 
Javascript :: Regular Expression for Detect Iranian Mobile Phone Numbers | IR mobile number Regex Pattern 
Javascript :: javascript break foreach 
Javascript :: accept Post with no midleWare express 
Javascript :: javascript scroll to top 
ADD CONTENT
Topic
Content
Source link
Name
4+4 =