Grokking Advanced JavaScript
Vote

0% completed

​

Constructor Functions

How do you create fifty car objects that all have the same properties and the same methods, without writing fifty object literals? One answer is a function that builds each object for you.

A constructor function is an ordinary function that is meant to be called with the new keyword. The new keyword creates the object, and the function fills it in. By convention, the name of a constructor function starts with a capital letter, so a reader can tell that it must be called with new.

function FuncName(param1, param2) { // Set properties on this }

.....

.....

.....

Like the course? Get enrolled and start learning!

Reading Progress

0%


Vote for new content