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

javascript  基礎

Posted at

『学習備忘録』

typeof: 型を調べるもの
number: 数値を表すデータ型(整数、小数)

.js
if (typeof hoge !== 'number')
// hogeがnumber型ではない時にtrueを返す
// numberとすると変数という認識になってしまうため''で囲う

if (!Number.isInteger(hoge))
// hogeが整数ではない時にtrueを返す 内部ではnumber型かどうか、整数かどうかを確認している

if (typeof hoge !== 'number' || !Number.isInteger(hoge) || hoge < 1 || hoge > 7) {
  return null;
}
// hogeというものが上記のどこかでtrueになるとnullを返す
1
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
1
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?