| [ Web Proxy ] |
| Viewing: https://developer.mozilla.org/ja/docs/Web/JavaScript/Reference/Global_Objects/Function/prototype | [Back] [Original] |
Get to know MDN better
:
Function prototype
Function: prototype | |
|---|---|
new prototype
function Ctor() {}
const inst = new Ctor();
console.log(Object.getPrototypeOf(inst) === Ctor.prototype); // true
async function* asyncGeneratorFunction() {}
function* generatorFunction() {}
prototype new prototype Generator
prototype new Symbol() BigInt() new Symbol.prototype BigInt.prototype
prototype prototype
const method = { foo() {} }.foo;
const arrowFunction = () => {};
async function asyncFunction() {}
prototype
class Class {}
function fn() {}
const boundFunction = function () {}.bind(null);
prototype 1 constructor constructor
prototype Object new Object.prototype new prototype
function Ctor() {}
Ctor.prototype = 3;
console.log(Object.getPrototypeOf(new Ctor()) === Object.prototype); // true
function Ctor() {}
const p1 = new Ctor();
const p2 = new Ctor();
Ctor.prototype.prop = 1;
console.log(p1.prop); // 1
console.log(p2.prop); // 1
Error.prototype.name prototype
class Dog {
constructor(name) {
this.name = name;
}
}
Dog.prototype.species = "dog";
console.log(new Dog("Jack").species); // "dog"
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 |