JavaScript Core Concept

anondo bormon
3 min readMay 8, 2021

JavaScript Truty and Falsy: In javaScript, if/else statement check true or false condition. if the condition is true then return a true value otherwise false. we see some example below:

When we are using number value in if/else condition for check result is true or false. if we are using 0 in condition then return false otherwise return true at list without 0 number everything return number true in number value. Example below.

// Falsy value// 0, -0, '', false, null, undefiend, NaN

Null vs Undefined: Undefined and Null closely same but they are different in form. This article will explore the difference between null and undefined. Let’s start.

Undefined: Undefined means if we don't define anything or don't declare any variable value that's return undefined. We get undefined like 6 to 7 way. Example below:

let names;
condole.log(names)// except output: undefined
// there is dont't return anyting therefore return undifiendfunction sum(num1, num2){ }
const output = sum(12, 22)
console.log(output);

If we declare an object and declare some property and value. there are we create a student object and have to property name, roll if we want to read sub property value from an object that returns an undefined value. Example below:

Null: Usually null is empty or non-existing value & need to defined value null that’s return null.

const name = null;
condole.log(name) // except output: null

Diffarence between == or === :

(==) means Abstract Equality Comparison. Usually == compare two values are after converting both values to a common type. == don’t care of value type. An example below:

And (===) Strict Equality comparison. Usually, compare two values. === take extra-care of values type if value type is different this return unequal. if values are the same type and same value they return equal.

Find the largest element in the array example below:

Remove duplicate item in the array below an example:

Reverse a string: There have a sting if we want to do reverse then we follow this example.

Calculate factorial: If we want to get 3 numbers of factorial so what we do that 3*2*1 right? this work procedure we do in a write a program.

--

--