TGViewer
Web Development - HTML, CSS & JavaScript Web Development - HTML, CSS & JavaScript @javascript_courses ยท 55.7K subscribers
Post #3594 2.85K
๐Ÿš€ JavaScript Interview Questions with Answers โ€” Part 1

1. What is JavaScript?

JavaScript is a high-level, interpreted programming language used to create interactive and dynamic web pages. It runs in web browsers and can also be used for backend development with Node.js.

Common Uses:

Interactive websites

Form validation

Animations

API calls

Web applications

Backend development

Example:

console.log("Hello JavaScript");


2. What are the different data types in JavaScript?

JavaScript has two categories of data types.

Primitive Data Types

String

Number

Boolean

Undefined

Null

BigInt

Symbol

Non-Primitive (Reference) Data Types

Object

Array

Function

Example:

let name = "Deepak";   // String
let age = 25; // Number
let isActive = true; // Boolean
let data = null; // Null
let value; // Undefined


3. What is the difference between var, let, and const?

Feature | var | let | const

Scope | Function | Block | Block

Reassign | โœ… Yes | โœ… Yes | โŒ No

Redeclare | โœ… Yes | โŒ No | โŒ No

Hoisted | โœ… Yes | โœ… Yes (TDZ) | โœ… Yes (TDZ)

Example:

var a = 10;
let b = 20;
const c = 30;


Interview Tip:

Use const by default, let when the value changes, and avoid var in modern JavaScript.

4. What are primitive and non-primitive data types?

Primitive Data Types

Stored by value.

Examples:

String

Number

Boolean

Null

Undefined

BigInt

Symbol

Non-Primitive Data Types

Stored by reference.

Examples:

Objects

Arrays

Functions

Example:

let a = 10;
let b = a;
b = 20;

console.log(a); // 10


Reference Example:

const obj1 = { name: "John" };
const obj2 = obj1;
obj2.name = "Mike";
console.log(obj1.name); // Mike


5. What is type coercion?

Type coercion is JavaScript's automatic conversion of one data type into another during operations or comparisons.

Example:

console.log("5" + 2); // "52"
console.log("5" - 2); // 3


Types:

Implicit coercion (automatic)

Explicit coercion (manual)

Explicit Example:

Number("10"); // 10
String(100); // "100"


6. What is the difference between == and ===?

== (Loose Equality)

Compares values only

Performs type conversion

=== (Strict Equality)

Compares both value and data type

No type conversion

Example:

console.log(5 == "5");   // true
console.log(5 === "5"); // false


Best Practice:

Always prefer === to avoid unexpected results.

7. What are truthy and falsy values?

Truthy Values

Values treated as true in a boolean context.

Examples:

Non-empty strings

Non-zero numbers

Objects

Arrays

Falsy Values

JavaScript has these falsy values:

false

0

-0

0n

"" (empty string)

null

undefined

NaN

Example:

if ("Hello") {
console.log("Truthy");
}
if (0) {
console.log("Won't execute");
}


8. What is undefined?

undefined means a variable has been declared but has not been assigned a value.

Example:

let value;
console.log(value);


Output:

undefined

Key Point:

undefined is assigned automatically by JavaScript.

9. What is null?

null represents an intentional absence of any object value.

It is assigned manually by the developer.

Example:

let user = null;
console.log(user);


Output:

null

Difference:

undefined โ†’ No value assigned.

null โ†’ Empty value assigned intentionally.

10. What is NaN?

NaN stands for Not a Number.

It represents an invalid numeric result.

โค๏ธ Double Tap For Part 2
  • โค 13
  • ๐Ÿ‘ 1
More from @javascript_courses
  1. Oct 7, 2026๐— ๐—ฎ๐˜€๐˜๐—ฒ๐—ฟ ๐—ฃ๐—ผ๐˜„๐—ฒ๐—ฟ ๐—•๐—œ ๐—ณ๐—ผ๐—ฟ ๐—™๐—ฅ๐—˜๐—˜! ๐Ÿ”ฅ Learn Power BI through these FREE learninโ€ฆ
  2. Oct 4, 2026DSA Handwritten Notes
  3. Sep 28, 2026To learn web design and development from basic to advanced levels, you can follow these stโ€ฆ
  4. Sep 27, 202610 Websites Every Developer & AI Enthusiast Should Bookmark โœ… roadmap.sh โ€“ Step-by-step leโ€ฆ
  5. Sep 26, 2026๐Ÿ”น Escape Characters 2๏ธโƒฃ5๏ธโƒฃ New Line You can use \n and \t: const message1 = "Hello\nWorldโ€ฆ
  6. Sep 26, 2026const fileName = "report.pdf"; console.log(fileName.endsWith(".pdf")); // true ๐Ÿ”น Findingโ€ฆ
Threads Profile ViewerView any public Threads profile without an account.Open ThreadLook โ†’Writing with AI? Make it sound human.Metric37 rewrites AI drafts so they read naturally. Free AI detector, 1,500 words free.Try Metric37 โ†’