constructor is a function

This commit is contained in:
2024-06-03 12:16:54 +02:00
parent 1e55406e8f
commit 78ebe07977
3 changed files with 44 additions and 0 deletions

11
4.5constructor/t3.js Normal file
View 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);