8
9

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.

JavaScriptで「エクスクラメーションマーク2つ」の意味(`!! extensions.get( 'OES_texture_float' )`)

Last updated at Posted at 2016-04-24

背景

three.jsのソースを調べていたら、ビックリマーク2つの処理がありました。

three.js
this.floatFragmentTextures = !! extensions.get( 'OES_texture_float' );

やっていることはBooleanに変換しているだけです。
じゃあなんで以下のようにBooleanコンストラクタを使わないんですかね?

this.floatFragmentTextures = Boolean( extensions.get( 'OES_texture_float' ) );

「エクスクラメーションマーク2つ」の意味

下記のサイトに答えが書いてあるのだと思うんですが、英語のためよく分かりませんでした...
http://www.bennadel.com/blog/1784-using-double-not-operator-for-boolean-type-casting.htm

Pretty slick. So, why would you want to do this? Well, in jQuery, there are methods that work off of Boolean values (such as jQuery.grep() and jQuery.fn.filter()) and it's nice to have a concise way to perform such conversions. That said, James Padolsey points out in his jQuery Cookbook chapter (page 47):

参考サイト

http://www.penpale.jp/blog/double_exclamation_mark.html
http://stackoverflow.com/questions/784929/what-is-the-not-not-operator-in-javascript

8
9
2

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
8
9

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?