Please note, this is a STATIC archive of website developer.mozilla.org from 03 Nov 2016, cach3.com does not collect or store any user information, there is no "phishing" involved.

この記事はまだボランティアによって 日本語 に翻訳されていません。ぜひ MDN に参加して翻訳を手伝ってください!

A constructor belongs to a particular class object that is instantiated. The constructor initializes this object and can provide access to its private information. The concept of a constructor can be applied to most object-oriented programming languages. Essentially, a constructor in JavaScript is usually declared at the instance of a class.

Syntax

// This is a generic default constructor class Default
function Default() {
}

// This is an overloaded constructor class Overloaded 
// with parameter arguments 
function Overloaded(arg1, arg2, ...,argN){
}

To call the constructor of the class in JavaScript, use a new operator to assign a new object reference to a variable.

function Default() {
}

// A new reference of a Default object assigned to a 
// local variable defaultReference
var defaultReference = new Default();

 

Learn more

General knowledge

Technical reference

ドキュメントのタグと貢献者

 このページの貢献者: maybe, PetiPandaRou, Andrew_Pfeiffer, hbloomer, pbmj5233, klez, vdmannvol
 最終更新者: maybe,