Difference between revisions of "Constructors"
Jump to navigation
Jump to search
| Line 2: | Line 2: | ||
=Constructor= | =Constructor= | ||
<pre> | <pre> | ||
function | function Balance(current, deposit){ | ||
this. | this.current = current; | ||
this. | this.deposit = deposit; | ||
this.display=function(){ | this.display=function(){ | ||
current +=deposit; | |||
console.log( | console.log(current); | ||
} | } | ||
} | } | ||
var balance = new Balance(100,24); | |||
var | balance.display(); | ||
</pre> | </pre> | ||
Revision as of 23:00, 20 October 2016
Constructor
function Balance(current, deposit){
this.current = current;
this.deposit = deposit;
this.display=function(){
current +=deposit;
console.log(current);
}
}
var balance = new Balance(100,24);
balance.display();