MozTW 討論區 https://forum.moztw.org/ |
|
function 內的 length-arguments? https://forum.moztw.org/viewtopic.php?f=13&t=14951 |
第 1 頁 (共 1 頁) |
發表人: | Mask [ 2006-07-25, 20:05 ] |
文章主題 : | function 內的 length-arguments? |
google 函式預設值看到的,原始網頁的有上點色,看起來應該會比較舒服。 疑問是 _f.length-arguments.length 當中的 length-arguments 指的是什麼?謝謝。 代碼: Function.prototype.defaults = function()
{ var _f = this; var _a = Array(_f.length-arguments.length).concat( arguments.length-1?Array.apply(null, arguments): [arguments[0]]); return function() { return _f.apply(_f, (arguments.length-1 ? Array.apply(null, arguments) : [arguments[0]]).concat( _a.slice(arguments.length, _a.length))); } } |
發表人: | 風痕影 [ 2006-07-26, 22:43 ] |
文章主題 : | |
呃,個人覺得那個 Array() 中所寫的可能是... _f.length 減(-) arguments.length 的意思 XD |
發表人: | Mask [ 2006-07-27, 19:53 ] |
文章主題 : | |
風痕影 寫: 呃,個人覺得那個 Array() 中所寫的可能是...
_f.length 減(-) arguments.length 的意思 XD 唉唉~居然忘記變數的命名規則 =_= 真是一語驚醒夢中人,太感謝了。 |
發表人: | 風痕影 [ 2006-07-27, 22:48 ] |
文章主題 : | |
老實說看到標題時我也嚇了一大跳 想說怎麼會有這種命名呢 ^^" |
第 1 頁 (共 1 頁) | 所有顯示的時間為 UTC + 8 小時 |
Powered by phpBB® Forum Software © phpBB Group https://www.phpbb.com/ |