[ Web Proxy ]
URL:
Viewing: https://developer.mozilla.org/ko/docs/Web/JavaScript/Reference/Errors/Not_a_constructor [Back]  [Original]

TypeError: "x" is not a constructor - JavaScript | MDN

This page was translated from English by the community. Learn more and join the MDN Web Docs community.

View in English Always switch to English

TypeError: "x" is not a constructor

    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

In this article

TypeError

?

, ( ) . constructor new operator .

String Array new, . . JavaScript : Math, JSON, Symbol, Reflect, Intl, SIMD, Atomics.

Generator functions .

js
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 . :

js
function Car(make, model, year) {
  this.make = make;
  this.model = model;
  this.year = year;
}

mycar :

js
var mycar = new Car("Eagle", "Talon TSi", 1993);

* Promise(...)* .

( ). TypeError: this is not a constructor :

js
return new Promise.resolve(true);

, Promise.resolve() Promise.reject() :

js
// 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);


Web Proxy Viewer  |  New URL  |  Original Page