LoginSignup
1
0

More than 5 years have passed since last update.

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

Posted at

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

利用するバージョン

underscore.js(v1.8.3)

nowとは

underscorejs.orgのnow

こんな説明。

_.now()

Returns an integer timestamp for the current time, using the fastest method available in the runtime.
Useful for implementing timing/animation functions.

_.now();
=> 1392066795351

ランタイム上で利用できるもっとも早い方法を利用し、現在時刻をintegerのタイムスタンプを返します。
タイミングやアニメーションの関数を実行する時に役立ちます

underscore.now

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

  // A (possibly faster) way to get the current timestamp as an integer.
  _.now = Date.now || function() {
    return new Date().getTime();
  };


Date.nowを用いるか、存在しない場合はDateをnewしたものからgetTime関数を用いて返す。

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