Function is one type of object.
function Person(first, last, age, eye) {
this.firstName = first;
this.lastName = last;
this.age = age;
this.eyeColor = eye;
}
“this” refers to the Person. Then “This.firstName” is the property of function Person.
class Car {
constructor(name, year) {
this.name = name;
this.year = year;
}
}
The example above creates a class named “Car”.
The class has two initial properties: “name” and “year”.
https://www.w3schools.com/js/js_classes.asp
I have the following question.
Example:
class Calculator {
constructor(previousOperandTextElement, currentOperandTextElement) {
this.previousOperandTextElement = previousOperandTextElement
this.currentOperandTextElement = currentOperandTextElement
this.clear()
}
clear() {
**this.currentOperand** = ''
this.previousOperand = ''
this.operation = undefined
}
My question is:
whether “this.currentOperand” is the property of the “clear()” or the property of the “class Calculator”??