VALUES, TYPES AND OPERATOR
🚗 in 👨 or
👨 in 🚗,
In the real project. We can compare two strings values with each other without any problem (maybe I said that). In that, the comparison order takes precedence from
"a-zA-Z0-9" in descending order.
Don't trust me, press F12 and make some calculates.
"a" > "A" => ? "Z" > "0" => ? "A" > "0" => ? "a" > 0 => ?
NaN values Not-A-Number 👽👾,
is a property of the global object or the global scope. NaN is a non-configurable, non-writable property. Even when this is not the case, avoid overriding it. And there are things of rules in NaN: number cannot be parsed
parseInt("Tom Haland"), math operation where the result is not a number
Math.sqrt(-100), operand of an argument is NaN
10 * NaN, Indeterminate form
0 * Infinity,
Empty values ☁,
null in other programming language. But
null in JS is different, that is object, don't trust me, checking
typeof(null) === "object" you will see result make you amazing 😃😃😃. They are used for announcing an application variable that has not been declared or defined - like an owner who is away from home and of course we know whose home it is. By default, using
null, undefiend is not too mandatory to use which type in a real project. just choose and use the type base on the design in your system.
Automatic type conversion 🚗=🚓,
- Any value (i.e null, number, string) * 0 => 0, except
- String + number => "String + number"
- String - number => number
- String * number => NaN
- Boolean == 0 => true
- Null == undefined => true
- Null == 0 => false
Short-Circuiting of logical operator 👌🤦♂️🤷♂️,
this operator is logical of two different data types with the purpose of being able to handle data. For
&&, || with each of them make different results.
"Tom" && "That is Tom" => "That is Tom"
The value starts from left to right side, if the value of left side is **truthy* type then the next value will be the result.
"Tom" || "Hill" => "Tom"
In this case, which value is **truthy*, then take that value to result.
Truethy not include:
false, 0, -0, 0n, “”, null, undefined, NaN
Absolute comparison 👩⚖️,
Absolute comparison between two types of values. Because JS is a dynamic programming language should be a means of comparison for sure as the final result must be absolutely accurate.
===, an ambiguity method of salvation of value type.
And as before, we have seen that
null == undefined => true, but when adding an
= sign, everything goes in a different direction,
null === undefined => false.
===is a righteous Judge. Everything is right and wrong. Will not tolerate any public under the jurisdiction of Judge
I hope it helps a little bit.
Thanks for reading my post.
Have a nice day!
Top comments (0)