How to check variable type in JavaScript

1 Answer

0 votes
const b = true; 
const n = 34587;
const s = "javascript";
 
const obj = {
  id: 123,
  name: "tom",
  salary: 12900,
  work: true
}
 
 
console.log(typeof b); 
console.log(typeof n); 
console.log(typeof s); 
console.log(typeof obj); 
console.log(typeof obj.id); 
console.log(typeof X); 
 
    
        
        
        
/*
run:
    
"boolean"
"number"
"string"
"object"
"number"
"undefined"
    
*/
  

 



answered Jun 14, 2021 by avibootz
edited Feb 4, 2022 by avibootz

Related questions

1 answer 302 views
1 answer 197 views
1 answer 283 views
8 answers 1,049 views
1 answer 258 views
1 answer 221 views
...