As new on JS developpment, I've started the OOP which from my point of view is the more dificult but also the most intersting part of JS.
There is my code :
var calc = function(num1, num2){
this.num1 = num1;
this.num2 = num2;
this.addNum2 = function(number){
this.num2 = number;
}
}
And now, I'm trying to use the function addNum2to set the num2 with
calc.addNum2(24)
I got this return:
VM495:1 Uncaught TypeError: calc.addNum2 is not a function
I'm just here to understand how it works so any help would be precious. Thank you all!
calcis a construtor which constructs an object which has the methodaddNum2. You use it asnew calc(a, b)first…