JavaScript Constructor MethodA JavaScript constructor method is a special type of method which is used to initialize and create an object. It is called when memory is allocated for an object. Points to remember
Constructor Method ExampleLet's see a simple example of a constructor method. Test it NowOutput: 101 Martin Roy Constructor Method Example: super keywordThe super keyword is used to call the parent class constructor. Let's see an example. Test it NowOutput: 1 John Javatpoint Note - If we didn't specify any constructor method, JavaScript use default constructor method.
Next TopicJS static Method
|
JavaTpoint offers too many high quality services. Mail us on h[email protected], to get more information about given services.
JavaTpoint offers college campus training on Core Java, Advance Java, .Net, Android, Hadoop, PHP, Web Technology and Python. Please mail your requirement at [email protected].
Duration: 1 week to 2 week