0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

typeofの概要メモ[JavaScript]

Last updated at Posted at 2021-06-16

MDNで調べたことを備忘録としてメモします。
現在はMDNからの引用が中心ですが、今後、使ってみて便利だと感じたケースなども追記していきたいと思っています。

typeof 演算子は、未評価のオペランドの型を示す文字列を返します。

example.js
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"

##構文

typeof 演算子の後に、オペランドを続けて書きます。

typeof operand
typeof(operand)

##typeof が返す事が出来る値 (文字列) の一覧表

返値
Undefined "undefined"
Null "object"
真偽値 "boolean"
数値 "number"
BigInt (ECMAScript 2020 の新機能) "bigint"
文字列 "string"
シンボル (ECMAScript 2015 の新機能) "symbol"
Function オブジェクト (implements [[Call]] in ECMA-262 terms) "function"
その他のオブジェクト "object"

※Nullの場合も"object"を返す

##参考
typeof - JavaScript | MDN

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?