TypeError: More arguments needed

๋ฉ”์‹œ์ง€

TypeError: argument is not an Object and is not null (Edge)
TypeError: Object.create requires at least 1 argument, but only 0 were passed
TypeError: Object.setPrototypeOf requires at least 2 arguments, but only 0 were passed
TypeError: Object.defineProperties requires at least 1 argument, but only 0 were passed

์—๋Ÿฌ ํƒ€์ž…

TypeError.

๋ฌด์—‡์ด ์ž˜ ๋ชป ๋˜์—ˆ์„๊นŒ?

ํ•จ์ˆ˜ ํ˜ธ์ถœ ์‹œ ์—๋Ÿฌ๊ฐ€ ์žˆ์Šต๋‹ˆ๋‹ค. ๋” ๋งŽ์€ ์ธ์ˆ˜๊ฐ€ ์ฃผ์–ด์ ธ์•ผ ํ•ฉ๋‹ˆ๋‹ค.

์˜ˆ์ œ

Object.create() ๋ฉ”์„œ๋“œ๋Š” ์ ์–ด๋„ 1๊ฐœ์˜ ์ธ์ž๊ฐ€ ํ•„์š”ํ•˜๋ฉฐ, Object.setPrototypeOf() ๋ฉ”์„œ๋“œ๋Š” ์ ์–ด๋„ 2๊ฐœ์˜ ์ธ์ž๊ฐ€ ํ•„์š”ํ•ฉ๋‹ˆ๋‹ค.:

var obj = Object.create();
// TypeError: Object.create requires at least 1 argument, but only 0 were passed

var obj = Object.setPrototypeOf({});
// TypeError: Object.setPrototypeOf requires at least 2 arguments, but only 1 were passed

์˜ˆ๋ฅผ ๋“ค๋ฉด, ์ด๋ ‡๊ฒŒ ํ”„๋กœํ†  ํƒ€์ž…์œผ๋กœ  null๋ฅผ ์„ธํŒ…ํ•ด์„œ ๊ณ ์น  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.:

var obj = Object.create(null);

var obj = Object.setPrototypeOf({}, null);

์ฐธ์กฐ