Vanilla-JavaScript-Calculator | Pure vanilla JavaScript calculator using modern ES6 syntax and classes | Script Programming library
kandi X-RAY | Vanilla-JavaScript-Calculator Summary
kandi X-RAY | Vanilla-JavaScript-Calculator Summary
Pure vanilla JavaScript calculator using modern ES6 syntax and classes
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
Currently covering the most popular Java, JavaScript and Python libraries. See a Sample of Vanilla-JavaScript-Calculator
Vanilla-JavaScript-Calculator Key Features
Vanilla-JavaScript-Calculator Examples and Code Snippets
Community Discussions
Trending Discussions on Vanilla-JavaScript-Calculator
QUESTION
I am a beginner in coding and while following YouTube channel WebDevSimplified, I came across below JS code for making a calculator. In the below code, I am not able to understand, how currentOperand
and previousOperand
are being used without defining? It looks like currentOperand
is referencing to currentOperandTextElement
and previousOperand
to previousOperandTextElement
, However its not defined anywhere in code. below is the link for GitHub repo
https://github.com/WebDevSimplified/Vanilla-JavaScript-Calculator/blob/master/script.js
Request you all to help me understand. Thank you so much.
...ANSWER
Answered 2021-May-25 at 16:42currentOperand
and previousOperand
are dynamically being created as fields on the class Calculator
. Since both of them were not defined in the constructor, their initial value is undefined
.
For example, as operations are performed on the calculator by appendNumber
, this.currentOperand
is assigned a value, which can be used later by chooseOperation()
and compute()
.
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install Vanilla-JavaScript-Calculator
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page