Search This Blog

Javascript: check variable type

const a = 1;
const b = '2';

console.log(typeof a); // 'number'
console.log(typeof a === 'number'); // true

console.log(typeof b); // 'string'
console.log(typeof b === 'string'); // true

No comments:

Post a Comment