0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

厳格な等価性と抽象的な等価性

JavaScript特有の文法である=====の使い分けをまとめます。

厳格な等価性(===)

2つのオペランドを比較して論理値で結果を返す。
2つのオペランドの型が異なる場合には常に偽と判断する。

console.log('Hello' === 'Hello');
> true

console.log('Hello' === 'hogehoge');
> false

console.log('1' === 1);
> false

console.log(0 === false);
> false

抽象的な等価性(==)

2つのオペランドの型変換を行い、比較してから論理値で結果を返す。

console.log('Hello' == 'Hello');
> true

console.log('10' == 10);
> true

console.log('false' == 0);
> true

console.log(0 == undefined);
> true

参考文献

0
1
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
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?