[ Web Proxy ]
URL:
Viewing: https://developer.mozilla.org/ja/docs/Web/JavaScript/Reference/Global_Objects/Function/prototype [Back]  [Original]

Function: prototype - JavaScript | MDN

MDN Web Docs

View in English Always switch to English

Function: prototype

prototype Function new

: Function prototype

Function: prototype

: prototype prototype

new prototype

js
function Ctor() {}
const inst = new Ctor();
console.log(Object.getPrototypeOf(inst) === Ctor.prototype); // true

prototype

prototype prototype new

js
async function* asyncGeneratorFunction() {}
function* generatorFunction() {}

prototype new prototype Generator

prototype new Symbol() BigInt() new Symbol.prototype BigInt.prototype

prototype prototype

js
const method = { foo() {} }.foo;
const arrowFunction = () => {};
async function asyncFunction() {}

prototype

js
class Class {}
function fn() {}

prototype

js
const boundFunction = function () {}.bind(null);

prototype 1 constructor constructor

prototype Object new Object.prototype new prototype

js
function Ctor() {}
Ctor.prototype = 3;
console.log(Object.getPrototypeOf(new Ctor()) === Object.prototype); // true

prototype

js
function Ctor() {}
const p1 = new Ctor();
const p2 = new Ctor();
Ctor.prototype.prop = 1;
console.log(p1.prop); // 1
console.log(p2.prop); // 1

prototype

Error.prototype.name prototype

js
class Dog {
  constructor(name) {
    this.name = name;
  }
}

Dog.prototype.species = "dog";

console.log(new Dog("Jack").species); // "dog"

js
class Dog {
  static {
    Dog.prototype.species = "dog";
  }
  constructor(name) {
    this.name = name;
  }
}

console.log(new Dog("Jack").species); // "dog"

ECMAScript 2027 LanguageSpecification
# sec-function-instances-prototype


Web Proxy Viewer  |  New URL  |  Original Page