constructor is a function
This commit is contained in:
11
4.5constructor/t3.js
Normal file
11
4.5constructor/t3.js
Normal file
@@ -0,0 +1,11 @@
|
||||
function Accumulator(startingValue){
|
||||
this.value = startingValue;
|
||||
this.read = function(){
|
||||
new_value = +prompt("value?", 0);
|
||||
this.value += new_value;
|
||||
}
|
||||
}
|
||||
|
||||
let accumulator = new Accumulator(1);
|
||||
accumulator.read();
|
||||
alert(accumulator.value);
|
Reference in New Issue
Block a user