Heey,
I'm a beginner learning JavaScript and I was seeing a tutorial of how to make a calculator by WebDevSimplified channel on youtube, I'd say I understood most of the code, but I have a doubt about some properties created inside of the methods of the class. For example:
class Calculator {
constructor(previousOperandTextElement, currentOperandTextElement) {
this.previousOperandTextElement = previousOperandTextElement
this.currentOperandTextElement = currentOperandTextElement
this.clear()
}
clear() {
this.currentOperand = ''
this.previousOperand = ''
this.operation = undefined
}
Please correct me if I'm wrong, he creates the class, then the constructor, and finally he set two parameters to it and assigned these parameters to two properties. What I'm not understanding is the properties inside of the methods(the "clear" method for example), in this code above he sets the parameters: currentOperand, previousOperand and operation. How do the "system" understand that these are the current and previous operand numbers that are going to display in the screen since it's not linked to the HTML. I'll put the link of the entire project bellow.
https://github.com/WebDevSimplified/Vanilla-JavaScript-Calculator