メモ用サブブログ

子曰わく學びて時にこれを習う。

2014-01-29から1日間の記事一覧

JavaScript 引数を設定してない関数でもargumentsという変数で引数が取れる

> test = function(){ ... console.log("0:%s, 1:%s, 2:%s", arguments[0], arguments[1], arguments[2]); ... } [Function] > test() 0:undefined, 1:undefined, 2:undefined > test(1,2,3) 0:1, 1:2, 2:3 > test("wan","nyaa","wahaa") 0:wan, 1:nyaa, 2:w…

JavaScript Math.floorを使わずにビット演算で小数点を切り捨て

> Math.random()*16777216 1032588.9140625 > Math.random()*16777216<<0 15867770 Math.floorより高速ということかな? ネタ元:https://github.com/patrickkunka/easydropdown/blob/master/src/jquery.easydropdown.js 開眼! JavaScript ―言語仕様から学ぶ…