js 変数の型判別#
primitive型#
console.log(typeof 42);
// expected output: "number"
console.log(typeof 'blubber');
// expected output: "string"
console.log(typeof true);
// expected output: "boolean"
console.log(typeof undeclaredVariable);
// expected output: "undefined"
class#
if(dog instanceof Animal){
}
Related Notes#
References#
- https://developer.mozilla.org/ja/docs/Web/JavaScript/Reference/Operators/typeof
- https://developer.mozilla.org/ja/docs/Web/JavaScript/Reference/Operators/instanceof
Tags#
#js