TypeError: "x" is not a constructor TypeError: Math is not a constructor TypeError: JSON is not a constructor TypeError: Symbol is not a constructor TypeError: Reflect is not a constructor TypeError: Intl is not a constructor TypeError: SIMD is not a constructor TypeError: Atomics is not a constructorì¤ë¥ ì í ëê° ì못ë ê±°ì£ ?
ê°ì²´ í¹ì ë³ì를 ìì±ìë¡ ì¬ì©íë ¤ê³ íìµëë¤, íì§ë§ ê°ì²´(í¹ì ë³ì)ê° ìì±ìê° ìëëë¤. ìì±ìê° ë¬´ìì¸ì§ì ëí ìì¸í ì ë³´ë constructor í¹ì new
operator 를 참조íì기 ë°ëëë¤.
String
í¹ì Array
ì ê°ì´ new
,를 ì¬ì©íì¬ ìì±í ì ìë ì ì ê°ì²´ë¤ì´ ììµëë¤. íì§ë§ ì¼ë¶ ì ì ê°ì²´ë¤ì ê·¸ë ì§ ìê³ ìì±ê³¼ ë©ìëê° ì ì ì
ëë¤. ë¤ìì JavaScript íì¤ ë´ì¥ ê°ì²´ë¤ì ìì±ìê° ìëëë¤: Math
, JSON
, Symbol
, Reflect
, Intl
, SIMD
, Atomics
.
Generator functions ëí ìì±ìë¡ ì¬ì©ë ì ììµëë¤.
ìì ì í¨íì§ ìì ê²½ì°var Car = 1;
new Car();
// TypeError: Car is not a constructor
new Math();
// TypeError: Math is not a constructor
new Symbol();
// TypeError: Symbol is not a constructor
function* f() {}
var obj = new f();
// TypeError: f is not a constructor
car ìì±ì
ìëì°¨(car) ê°ì²´ë¥¼ ë§ë¤ê³ ì íë¤ê³ ê°ì í©ëë¤. ì´ ê°ì²´ì íì
ì car
ë¼ íê³ make, model, and year ì¸ ê°ì íë¡í¼í°ë¥¼ ê°ìµëë¤. ì´ë¥¼ ìí´ ë¤ìê³¼ ê°ì í¨ì를 ìì±í ê²ì
ëë¤:
function Car(make, model, year) {
this.make = make;
this.model = model;
this.year = year;
}
ì´ì ë¤ìê³¼ ê°ì´ mycar
ë¼ ë¶ë¦¬ë ê°ì²´ë¥¼ ìì±í ì ììµëë¤:
var mycar = new Car("Eagle", "Talon TSi", 1993);
íë¼ë¯¸ì¤ ì´ì©
ì¦ì ì¤íëë íë¼ë¯¸ì¤ë¥¼ ë°ííë ê²½ì°ìë *ìë¡ì´ Promise(...)*를 ìì±í íìê° ììµëë¤.
ìëë ì¬ë°ë¥¸ ë°©ë²ì´ ìëëë¤(íë¼ë¯¸ì¤ ìì±ìê° ì ëë¡ í¸ì¶ëê³ ìì§ ììµëë¤). TypeError: this is not a constructor
ìì¸ë¥¼ ëì§ê² ë©ëë¤:
return new Promise.resolve(true);
ëì , Promise.resolve() í¹ì Promise.reject() ì ì ë©ìë를 ì¬ì©íììì¤:
// This is legal, but unnecessarily long:
return new Promise((resolve, reject) => {
resolve(true);
});
// Instead, return the static method:
return Promise.resolve(true);
return Promise.reject(false);
ê°ì´ 보기
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