LoginSignup
1
1

More than 5 years have passed since last update.

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

Posted at

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

利用するバージョン

underscore.js(v1.8.3)

noConflictとは

underscorejs.orgのnoConflict

こんな説明。

_.noConflict()

Give control of the _ variable back to its previous owner. 
Returns a reference to the Underscore object.

var underscore = _.noConflict();

_の変数のコントロールを以前のオーナーに与える。?
underscoreのobjectの参照を返す。

underscore.noConflict

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


  // Run Underscore.js in *noConflict* mode, returning the `_` variable to its
  // previous owner. Returns a reference to the Underscore object.
  _.noConflict = function() {
    root._ = previousUnderscore;
    return this;
  };

root._にpreviousUnderscoreを代入する。
その後、thisを返す。

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