-0is considered equal to
Strict equality, SameValueZero, and SameValue are almost equivalent. They only differ in their handling of
-0. For all other values, the last 3 algorithms are identical.
NaN is not strictly equal to any value, not even itself. In other words,
NaN !== NaN. Also,
(+0) === (-0).
Object.is() function implements the SameValue algorithm. With the SameValue algorithm,
NaN is equal to itself:
Object.is(NaN, NaN) === true. But, on the other hand,
+0 is not equal to
Object.is(+0, -0) === false.
SameValueZero: There’s no way to use SameValueZero directly, but the Array#includes()
[method](https://masteringjs.io/tutorials/fundamentals/array-includes) uses SameValueZero internally. So, to try out SameValueZero, you can useincludes(). The only difference between SameValue and SameValueZero is that SameValueZero treats
+0 as equal to
[+0].includes(-0) === true.
As a developer, you should typically use
===, with the understanding that you may need to add a special case if you care about
NaN. The distinction between
-0 is not important for most use cases.
yare the same type, check if
x === y.
yare both either
xis a number and
yis a string, convert
yto a number and then compare using
===. Similarly, if
xis a boolean or string, and
yis a number, convert
xto a number.
yis a boolean, convert the other value of a number and compare them.
xis an object and
yis a symbol, string, or number, try to convert
xto a primitive using valueOf() and then compare using
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
With 15+ years of domain expertise, we have successfully delivered 13800+ projects and have successfully garnered 6800+ happy customers with 97%+ client retention rate.
The compound assignment operators consist of a binary operator and the simple assignment operator.
The binary operators, work with two operands. For example a+b where + is the operator and the a, b are operands. Simple assignment operator is used to assign values to a variable(s).
It’s quite common to modify values stored in variables. To make this process a little quicker, we use compound assignment operators.
You can also check my video tutorial compound assignment operators.
Let’s consider an example. Suppose price = 5 and we want to add ten more to it.
var price = 5;
price = price + 10;
We added ten to price. Look at the repetitive price variable. We could easily use a compound += to reduce this. We do this instead.
price += 5;
Awesome. Isn’t it? What’s the value of price now? Practice and comment below. If you don’t know how to practice check these lessons.
Lets bring down the price by 5 again and display it.
We use console.log command to display what is stored in the variable. It is very help for debugging.
Debugging let’s you find errors or bugs in your code. More on this later.
price -= 5;
Lets multiply price and show it.
and finally we will divide it.
If you have any doubts, comment below.