Javascript

Abdur Rahman
Nov 8, 2020

Some Javascript topics

  1. Truthy and Falsy values:

Truthy and Falsy value is an important interview question. Falsy values are 0, “”, undefined, null, false, and others values without Falsy values are Truthy values.

For Example:

const number = 0;

if (number) {

console.log(this value is true.);

} else {

console.log(this value is false.);

}

2. Null Vs Undefined:

Null vs Undefined is an interview question. You do not set value this called undefined. You find undefined in different ways but Null find must be set value is null.

For Example:

const name;

console.log(name);

// Output Value is Undefined.

3. double equal (==) vs triple equal (===):

You just see two value is equal you use double equal (==). You can see values property like string, boolean, and number both sides equal you use triple equal (==).

For Example:

const num1 = 0;

const num2 = “0”;

if (num1 == num2) {

console.log(this is true);

}

// this is true

if (num1 === num2) {

console.log(this is false);

}

// Undefined

4. Reverse a string:

Reverse a string is the most popular question in the interview. You can string reverse uses the javascript reverse() method.

For Example:

const name= [‘Abdur’, ‘Rahman’, ‘Dali’];
console.log(name);
// expected output: Array [“Abdur”, “Rahman”, “Dali”]

const reversed = name.reverse();
console.log(reversed);
// expected output: Array [“Dali”, “Rahman”, “Abdur”]

// Careful: reverse is destructive — it changes the original array.
console.log(name);
// expected output: Array [“Dali”, “Rahman”, “Abdur”]

5. Window:

Window is a global scope. You use console, location, history. It is into the window property. more javascript method in window property. You can set window property.

For Example:

console.log(location == window.location);

// it is true;

--

--