JavaScript Constructors
 

JavaScript Constructors

An object constructor is a JavaScript method to define a basic object element. It is then used by defining a "new" instance of that object.

While this may seem to be a little confusing it is actually quite logical. HTML Elements are mostly predefined by the HTML Stanadard. However, the Standard also allows tne capability of creating you own custom objects with methods and attributes. As webmasters we all are well aware of the "standard" elements such as Paragraphs, INPUT, Headers, containers (DIVs) etc., some other predifined objects such as images, error and console objects are less than obvious.

The JavaScript Constructor method is part of the Object Orientated nature of the Document Object Model

What I have tried to on this website is to feature areas of Advanced JavaScript that are both of interest to me and are maybe not well explained (or could be better explained).

The "Prototype" construct in JavaScript determines how objects pass-on behaviours by inheritance.

Top

The JavaScript Constructor came to my attention when I was analysing some of the code that I have using. The JavaScript Constructor Method is used when a class is created/defined/delclared

The AI summary above says:

The constructor method is defined within a class and is called automatically when a new instance of the class is created.

Useage

The Constructor Method

Links

Link to PDF Disabled

If you require a copy please email tempusfugit.me.uk

Top

References -

  • 1 - Constructor, operator "new" - https:// javascript.info/ constructor-new
  • 2 - Introduction of Object Oriented Programming - https:// www.geeksforgeeks.org/ dsa/introduction-of- object-oriented-programming/