Function.prototype.length
Baseline
Widely available
This feature is well established and works across many devices and browser versions. Itâs been available across browsers since â¨2015ë 7ìâ©.
í¨ì ì¸ì¤í´ì¤ì length ë°ì´í° ìì±ì í¨ìê° ê¸°ëíë ì¸ìì ì를 ëíë
ëë¤.
ìëí´ ë³´ê¸°
function func1() {}
function func2(a, b) {}
console.log(func1.length);
// Expected output: 0
console.log(func2.length);
// Expected output: 2
ê°
ì«ì
Property attributes of Function.prototype.length | |
|---|---|
| ì°ê¸° ê°ë¥ | ë¶ê°ë¥ |
| ì´ê±° ê°ë¥ | ë¶ê°ë¥ |
| ì¤ì ê°ë¥ | ê°ë¥ |
ì¤ëª
lengthë í¨ì ê°ì²´ì ìì±ì¼ë¡, í¨ìê° ì¼ë§ë ë§ì ì¸ì를 기ëíëì§ ëíë
ëë¤, ì¦ íì 매ê°ë³ìì ì.
ì´ ìë ëë¨¸ì§ ë§¤ê°ë³ì를 í¬í¨íì§ ììµëë¤.
ê·¸ì ë°í´, arguments.lengthë í¨ìì
ì§ì(local)ì´ê³ ì¤ì ë¡ í¨ìì ì ë¬ë ì¸ìì ì를 ì ê³µí©ëë¤.
Function ê°ì²´ì length ìì±ì í¨ìê° ì¼ë§ë ë§ì ì¸ì를 기ëíëì§ ëíë
ëë¤. ì´ë íì 매ê°ë³ìì
ì ì
ëë¤. ì´ ì«ìë ëë¨¸ì§ ë§¤ê°ë³ì를 í¬í¨íì§
ìì¼ë©° 기본 ê°ì ê°ì§ 첫 ë²ì§¸ 매ê°ë³ì ì´ì ì ë§¤ê° ë³ìë§ í¬í¨í©ëë¤. ë°ë©´
arguments.lengthë íëì í¨ìì êµíëì´
ì¤ì ë¡ í¨ìì ì ë¬ë ì¸ìì ì를 ì ê³µí©ëë¤.
Function ìì±ìë ê·¸ ìì²´ë¡ function ê°ì²´ì
ëë¤. ê·¸ length ë°ì´í° ìì±ì ê°ì´
1ì
ëë¤.
ìì¬ì ì¸ ì´ì ë¡ ì¸í´ Function.prototypeì í¸ì¶ ê°ë¥í ìì²´ì
ëë¤. Function.prototypeì
lengthìì± ê°ì 0ì
ëë¤.
ìì
>í¨ì length ì¬ì©í기
console.log(Function.length); // 1
console.log((() => {}).length); // 0
console.log(((a) => {}).length); // 1
console.log(((a, b) => {}).length); // 2 etc.
console.log(((...args) => {}).length);
// 0, ëë¨¸ì§ ë§¤ê°ë³ìë ì¸ì§ ììµëë¤
console.log(((a, b = 1, c) => {}).length);
// 1, 기본ê°ì ê°ì§ 매ê°ë³ì ì´ì ì 매ê°ë³ìë§ ì
ëë¤
ëª ì¸ì
| Specification |
|---|
| ECMAScript® 2026 Language Specification > # sec-function-instances-length > |