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

More than 5 years have passed since last update.

underscoreコードリーディング(isBoolean)

Posted at

underscoreに詳しくないので、勉強半分でソースコードを読む。

利用するバージョン

underscore.js(v1.8.3)

isBooleanとは

underscorejs.orgのisBoolean

こんな説明。

####_.isBoolean(object)
Returns true if object is either true or false.

_.isBoolean(null);
=> false


objectがtrueもしくはfalseだった場合のみtrueを返します。

underscore.isBoolean

コード的にはこのあたり。


  // Is a given value a boolean?
  _.isBoolean = function(obj) {
    return obj === true || obj === false || toString.call(obj) === '[object Boolean]';
  };

obj自体がtrueかfalseに合致する、もしくはtoStringしたものが[object Boolean]に合致した場合にtrueを返す。

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