Baseline Widely available
Function
ì¸ì¤í´ì¤ì name
ìì±ì í¨ìê° ìì±ë ë ì§ì ë ëë¡ í¨ìì ì´ë¦ì ëíë´ê±°ë ìµëª
ì¼ë¡ ìì±ë í¨ìì ê²½ì° anonymous
ëë ''
(ë¹ ë¬¸ìì´)ì¼ ì ììµëë¤.
const func1 = function () {};
const object = {
func2: function () {},
};
console.log(func1.name);
// Expected output: "func1"
console.log(object.func2.name);
// Expected output: "func2"
ê°
문ìì´.
ì°ê¸° ê°ë¥ ë¶ê°ë¥ ì´ê±° ê°ë¥ ë¶ê°ë¥ ì¤ì ê°ë¥ ê°ë¥ì°¸ê³ : ë¹íì¤, ES6 ì´ì 구íììë configurable
ìì± ëí false
ììµëë¤.
name
ìì±ì í¨ì ì´ë¦ ëë (ES6 구í ì´ì ) ìµëª
(anonymous) í¨ìì ëí´ìë ë¹ ë¬¸ìì´ì ë°íí©ëë¤.
function doSomething() {}
console.log(doSomething.name); // logs "doSomething"
new Function(...)
ëë ê·¸ë¥ Function(...)
구문ì¼ë¡ ìì±ë í¨ìë name
ìì±ì ë¹ ë¬¸ìì´ë¡ ì¤ì í©ëë¤. ë¤ì ìììë ìµëª
í¨ìê° ìì±ëë¯ë¡ name
ì ë¹ ë¬¸ìì´ì ë°íí©ëë¤:
var f = function () {};
var object = {
someMethod: function () {},
};
console.log(f.name == ""); // true
console.log(object.someMethod.name == ""); // ìì true
ES6 í¨ì를 구íí ë¸ë¼ì°ì ë ìµëª í¨ì ì´ë¦ì ê·¸ 구문ì ìì¹ë¡ë¶í° ì¶ì¸¡í ì ììµëë¤. ì를 ë¤ì´:
var f = function () {};
console.log(f.name); // "f"
function ììì ì´ë¦ì¼ë¡ í¨ì를 ì ìí ì ììµëë¤:
var object = {
someMethod: function object_someMethod() {},
};
console.log(object.someMethod.name); // logs "object_someMethod"
try {
object_someMethod;
} catch (e) {
console.log(e);
}
// ReferenceError: object_someMethodê° ì ìëì§ ìì
í¨ì ì´ë¦ì ë°ê¿ ì ììµëë¤, ì´ ìì±ì ì½ê¸° ì ì©ì ëë¤:
var object = {
// ìµëª
someMethod: function () {},
};
object.someMethod.name = "someMethod";
console.log(object.someMethod.name); // ë¹ ë¬¸ìì´, someMethodë ìµëª
ê·¸ë¬ë ë°ê¾¸ë ¤ë©´, Object.defineProperty()
를 ì¬ì©í ì ììµëë¤.
ê°ì²´ì 'class'를 íì¸í기 ìí´ obj.constructor.name
ì ì¬ì©í ì ììµëë¤:
function a() {}
var b = new a();
console.log(b.constructor.name); // logs "a"
ëª
ì¸ì ë¸ë¼ì°ì í¸íì± ê°ì´ 보기
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4