// Option A
function Monster() {
this.growl = () => {
console.log ("Grr!");
}
}
// Option B
function Monster() {};
Monster.prototype.growl =() => {
console.log("Grr!");
}
Option A는 1000개의 메소드가 생성이되고, Option B는 1개의 메소드가 생성이 된다.
https://onecompiler.com/javascript/3ynj3u3wf
3ynj3u3wf - JavaScript - OneCompiler
Javascript Online Compiler Write, Run & Share Javascript code online using OneCompiler's JS online compiler for free. It's one of the robust, feature-rich online compilers for Javascript language. Getting started with the OneCompiler's Javascript editor is
onecompiler.com
https://medium.com/@bluesh55/javascript-prototype-%EC%9D%B4%ED%95%B4%ED%95%98%EA%B8%B0-f8e67c286b67
[Javascript ] 프로토타입 이해하기
자바스크립트는 프로토타입 기반 언어라고 불립니다. 자바스크립트 개발을 하면 빠질 수 없는 것이 프로토타입인데요. 프로토타입이 거의 자바스크립트 그 자체이기때문에 이해하는 것이 어렵
medium.com