Need to know 10 JavaScript Interview Question

JavaScript Truthy Values:

In JavaScript, a truthy value is considered true when encountered in boolean.

Truthy Values:

  1. Without zero (0) any number is truthy value.
  2. Without Empty String (“”) any string value is truthy value.
  3. Any Empty Array [ ] is truthy value.
  4. Any Empty Object { } is truthy value.

JavaScript Falsy Values:

In JavaScript, a falsy value is considered false when encountered in boolean.

Falsy Values:

  1. If any value is Undefined, the value is Falsy.
  2. If any value is Null, the value is Falsy.
  3. If any value is NaN, the value is Falsy.
  4. If any value is false (using this keyword), the value is Falsy.

Null VS Undefined:

Undefined: Undefined is the primitive value

  1. When the variable is declared but not assigned.
  2. When the function doesn't return value & return keyword.
  3. Some parameters is missing, When the function is called.
  4. The property of object doesn’t exist.
  5. The element of array doesn’t exist.
  6. When undefined is assigned to a variable.

Null: null represents the absence of object value intentionally. When a developer needs to a variable empty, then they set the value null to showing empty.

JavaScript Double Equal (==):

Double Equals (==) checks for value equality only. It inherently does type by force. That means before checking the values, it converts the types of the variables to match each other.

Example:

JavaScript Triple Equal (===):

Triple Equals (===) do not perform type by force. It will verify whether the variables being compared have both the same value AND the same type. That means it checks both Type & Value.

Example:

Problem Solving : Find the largest element in an array

Problem Solving : Reverse a String in JavaScript

Problem Solving : Calculate Factorial of a number using for loop

Problem Solving : Create a Fibonacci Series using a for loop

Problem Solving : Check whether a number is a Prime Number or not

--

--

--

Love podcasts or audiobooks? Learn on the go with our new app.

How Netflix and Paypal did product transformation using Node.js?

Login , Logout Sign-in , Sign-out in Django 3.5 with Class Views

Laravel Easy Form by Laravel H!

p5.js tutorials — particle systems

How To Create and Download Files in the Browser With Vanilla JavaScript

create file in javascript

React JS

Simple Spring Boot Service to Kubernetes Application: Step 16

Bubble Sort in a nutshell — how, when & where

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Khushbu Islam Misbah

Khushbu Islam Misbah

Web Developer

More from Medium

How JavaScript Engine Works

Javascript for revision

javascript

use-fetch-image is published to NPM today

“ Top 7 Things Must Know About JavaScript ”