Javascript part 6

Jonathan Bleibdrey
4 min readJan 11, 2021

--

Today we talk about different equal signs, Null and Undefined.

There are Three different types of equal signs, they are the single equal signs, double equal signs, and triple equal signs. Here is how to use them:

= : one equal sign sets a value

we have all seen this type of equal sign, if you have read any of my other javascript lectures you would know what this is...! All this does is set a variable with a value.

== : two equal signs are used to check if one element is equal to another element or “abstract equality.”

Here we are comparing a “number” and a “string”. You see that it returns “true,” even though it’s a string and a number. The javascript/computer will change one of the type’s of data via type conversion. (Not 100% how it happens but, it will convert one of the elements to the other element to make it true.)

=== : three equal signs are what they use to check “ strict equality.” (most often used)

We compare first a string and a number with only two equal signs, and it returns ‘true’. But, right below that, we see it return false when using a triple equal sign. It’s rigorous on what it compares to, so if it’s not the identical data type, it returns false(translation: if a number and number are being compared it will return true but, if it's a string and a number it will return false).

WHICH ONE SHOULD YOU USE?

It’s better to use the triple equals, for it will clarify your code and prevent any false positives caused by abstract equality. It’s better first to do the conversion then compare them. Moving on!

Null vs. Undefined:

in javascript undefined means that a variable has been declared but has not been defined yet(translation: has not been set with a value).

To add a value we simply set it by setting it to “it works.” with a single equal sign.

We use “Null” to represent a Null value(plain and simple, this value is nothing essentially.)

I feel the need to show what kind of data this is thought. Here we see that null is an object and undefined is undefined.

When comparing the “strict equality” returns false, but the “abstract equality” returns true.

In this last example(we play around!), we compare both strict and abstract equalities(==, ===), and they both return true. If we put an ! in front of it returns true since the value of null is false(flips the original value). If we put double !! in front of it, it goes back to its natural state which is false.

If we use null in math equations, it converts it to 0 because null is false so null + 1 will return 1.

Okay, that’s all I got for you today; thank you for your time. See you next week.

check out some javascript….

Javascript 1 (variables and data types)

Javascript 2 (numbers and strings)

Javascript 3 (bracket notation and 20 diff string methods)

Javascript 4 (functions and how they work)

Javascript 5 (hoisting, comparison operators, and if-else statements)

Javascript 6 (diff. Equal signs, null, and undefined)

Javascript 7 (logical operator, &&, || and ternary operators)

Javascript 8 (switch statements and arrays)

Javascript 9 (commonly used arrays in javascript)

Javascript 10 (Math. And parseInt Usage)

Javascript 11 (for loops and nested for loops)

Javascript 12(while loops and for..in and for..of loops)

Javascript 13(8 diff array methods)

Javascript 14(objects and ways to use objects)

Javascript 15(JSON and fetch request)

Javascript 16(“this” keyword)

Javascript 17(strict mode and error handling)

Javascript 18(setInterval/setTimeout and Dates)

React info…

React part 1 (How to start a react app)

React part 2 (components and dynamic values)

React part 3 (Multiple components and small styling)

React part 4 (click events with functions and react dev tools)

React part 5 (link to: useState hook and how to output lists in react)

React part 6 (Props and reusable components)

React part 7 (passing functions as props and use effect hook)

React part 8 (continue with useEffect hook, dependencies with useEffect, and setting up the JSON server to fetch)

React part 9 (Fetching data with JSON)

React part 10 (loading bar and fetch errors)

React part 11(custom hooks)

React part 12(React Router Dom, Exact, and Links)

The Social Media…

Github

Instagram

Facebook

Linked-In

Medium

--

--

Jonathan Bleibdrey
Jonathan Bleibdrey

Written by Jonathan Bleibdrey

Software engineer, Creator, Ball of Energy

No responses yet