You might not know these super handy Number methods yet.
The properties and methods on the Number type are not something that I work with every day, and it is one of the more looked up topics for me. It’s usually because of something that didn’t add up, like in the case of comparing floating-point numbers- which always surprises me, and I lose a few moments researching Number topics.
But they can be super helpful in providing an easy way to convert between bases (
toString), adding currency type or adhering to a certain number format based on the locale someone might be visiting (
Here are a few methods that can make manipulating and modifying numeric values much easier.
**Number()** method converts a string into a number.
// Example 1 let x = '10' let num = Number(x) console.log(num) // Output: 10 console.log(num * 9) // Output: 90 // Example 2 let x = true let num = Number(x) console.log(num) // Output: 1 console.log(num + 9) // Output: 10 //Example 3 let x = false let num = Number(x) console.log(num) // Output: 0 console.log(num + 9) // Output: 9
In the example above,
Number(value) method is used to convert string
x to an integer and perform operations on the number value. Setting
true returns 1 and
false returns 0.
Does your business need an interactive website or app?
The technology used to develop the overall app by the developers from WebClues Infotech is at par with the latest available technology.
For more inquiry click here https://bit.ly/31eZyDZ
Book Free Interview: https://bit.ly/3dDShFg
Callback: A callback is a function that is passed into another function as an argument to be executed later.
Events: Events provide a dynamic interface to a WebPage and are connected to elements in the Document Object Model(DOM), for example: onclick(), onmouseover() etc.
Pending: Before the event has happened, the promise is in the pending state.
Settled: Once the event has happened it is then in the settled state.
Fulfilled: Action related to the promise has succeeded.
Rejected: Action related to the promise has failed.