Dummy learn Javascript
Tags: javascript, basicjavascript
Published: 2020-12-03 13:31:14

---
title: Dummy learn Javascript
published: true
description: Javascript basic to me.
tags: #javascript #basicjavascript
cover_image: https://dev-to-uploads.s3.amazonaws.com/i/445e6ycd7gddbj5bae33.png
---
# VALUES, TYPES AND OPERATOR

The values, types or operators in JAVASCRIPT as well as other programming languages. Have types of data as String, Number, Boolean, Array, etc... Have operators as <code>"+, -, *, /, %"</code>. But each programming language has its own specialties. JAVASCRIPT just like that. Something stuck, something crazy, or something awesome that you meet when learning Javascript. And that why I see its interesting programming language. Here are the things of what I find out from books, the internet,...

***Infinity*** 🌌🌌🌌,
As it's meaning full. This is a special value in Javascript. When you do math operator with this value you will get the values in all the time are Infinity or NaN. I don't know what is that useful for? And I am advisable not to do calculations with this variable. Because the Infinity values are not necessary for use in practical applications. If that is not required.

***Comparison string*** <code>🚗 in 👨</code> or <code>👨 in 🚗</code>,
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 <code>"a-zA-Z0-9"</code> in descending order.

> Don't trust me, press F12 and make some calculates.

```bash
"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 <code>parseInt("Tom Haland")</code>, math operation where the result is not a number <code>Math.sqrt(-100)</code>, operand of an argument is NaN <code>10 * NaN</code>, Indeterminate form <code>0 * Infinity</code>, 

#### ***Empty values*** ☁,
<code>null, undefiend</code>there are both special values in Javascript - sometimes you will see <code>null</code> in other programming language. But <code>null</code> in JS is different, that is ***object***, don't trust me, checking <code>typeof(null) === "object"</code> 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 <code>null, undefiend</code> 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*** 🚗=🚓,
Because Javascript is a form of dynamic programming languages. So the types of values from there also become more flexible to use. The values auto covert base on the right type value or left value or operator in whatever case. There are some rules:
1. Any value (i.e null, number, string) * 0 => 0, except <code>undefined</code>.
2. String + number => "String + number"
3. String - number => number
4. String * number => NaN
5. Boolean == 0 => true
6. Null == undefined => true
7. 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 <code>&&, ||</code> with each of them make different results.
```javascript
"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.

```javascript
"Tom" || "Hill" => "Tom"
```
In this case, which value is ***truthy**, then take that value to result.

> ***Truethy*** not include: <code>false, 0, -0, 0n, “”, null, undefined, NaN</code>

#### ***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.

<code>===</code>, an ambiguity method of salvation of value type.

And as before, we have seen that <code>null == undefined => true</code>, but when adding an <code>=</code> sign, everything goes in a different direction, <code>null === undefined => false</code>.

> <code>===</code> is a righteous Judge. Everything is right and wrong. Will not tolerate any public under the jurisdiction of Judge <code>==</code>.

I hope it helps a little bit.
Thanks for reading my post.
Have a nice day!