Methods in Constructor Functions
This lesson teaches how to define and add new methods in a constructor function.
Defining Methods
Methods are defined differently in the constructor functions.
Example
We defined our methods inside the object literals in the following way:
Now, let’s write the same function but for the constructor function this time:
Explanation
In line 9 of the code for object literal, the method declaration was simple; the name of the function followed by the ...
Create a free account to access the full course.
By signing up, you agree to Educative's Terms of Service and Privacy Policy