Class에서 사용하지마!!!
class Test {
hello() {}
helloWorld = () => {}
}
const instance = new Test()
console.log(instance) // Test {helloWorld: ƒ}
console.log(Test.prototype) // {constructor: ƒ, hello: ƒ}
왜 Class 내에 Method를 선언 했는데 다르게 나올까??
var Test = /** @class */ (function () {
function Test() {
this.helloWorld = function () { };
}
Test.prototype.hello = function () { };
return Test;
}());
var instance = new Test();
console.log(instance); // Test {helloWorld: ƒ}
console.log(Test.prototype); // {constructor: ƒ, hello: ƒ}그러면 arrow function 써도 상관없는 거야???
메모리 할당보기
Chrome 메모리에 할당이 어떻게 되는지 확인해보자.


그러면 Arrow function은 어떤 문제가 있을까?
Last updated