Difference between revisions of "Constructors"
Jump to navigation
Jump to search
Line 1: | Line 1: | ||
=Constructor= | =Function Constructor= | ||
<pre> | <pre> | ||
function | var Person = function(name, yearOfBirth, job){ | ||
this.name = name; | |||
this.yearOfBirth = yearOfBirth; | |||
this.job = job; | |||
} | } | ||
var | |||
var john = new Person('john', 1967, 'teacher'); | |||
</pre> | </pre> | ||
==[[#top|Back To Top]]-[[Main_Page| Home]] - [[Java Script|Category]]== | ==[[#top|Back To Top]]-[[Main_Page| Home]] - [[Java Script|Category]]== |
Revision as of 17:08, 6 November 2016
Function Constructor
var Person = function(name, yearOfBirth, job){ this.name = name; this.yearOfBirth = yearOfBirth; this.job = job; } var john = new Person('john', 1967, 'teacher');