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 212 views
1 answer 110 views
1 answer 187 views
8 answers 648 views
1 answer 161 views
1 answer 134 views
...