TGViewer
App Development App Development @appdevelopmentofficial ยท 275 subscribers
Post #305 158
๐Ÿš€ JavaScript Interview Questions with Answers โ€” Part 2

11. What is the typeof operator?

The typeof operator is used to determine the data type of a value.

Example:

console.log(typeof "Hello");   // "string"
console.log(typeof 100); // "number"
console.log(typeof true); // "boolean"
console.log(typeof undefined); // "undefined"


Important Interview Point:

console.log(typeof null);


Output: "object"

This is a historical behavior in JavaScript.

12. What are template literals?

Template literals are strings created using backticks ``.

They allow you to easily embed variables and expressions using ${}.

Example:

const name = "Ajay";
const age = 25;

console.log(`My name is ${name} and I am ${age} years old.`);


Output: My name is Ajay and I am 25 years old.

Benefits:

Easy string interpolation

Supports multi-line strings

Allows expressions inside strings

13. What are JavaScript operators?

Operators are symbols used to perform operations on values.

Common Types:

Arithmetic: + - * / % **

Comparison: == === != !== > < >= <=

Logical: && || !

Assignment: = += -= *= /=

Example:

const a = 10;
const b = 5;
console.log(a + b); // 15
console.log(a > b); // true


14. What is the ternary operator?

The ternary operator is a short way of writing an if...else statement.

Syntax:

condition ? valueIfTrue : valueIfFalse;


Example:

const age = 20;
const result = age >= 18 ? "Adult" : "Minor";
console.log(result);


Output: Adult

Equivalent if...else:

if (age >= 18) {
result = "Adult";
} else {
result = "Minor";
}


Interview Tip: Use ternary operators for simple conditions. Avoid deeply nested ternaries because they reduce readability.

15. What is variable hoisting?

Hoisting is JavaScript's behavior of processing declarations before executing the code in their scope.

With var:

console.log(x);
var x = 10;


Output: undefined

The declaration is hoisted, but the assignment happens later.

With let and const:

console.log(x);
let x = 10;


This results in a ReferenceError.

let and const are hoisted but remain in the Temporal Dead Zone (TDZ) until their declaration is reached.

Function declarations are also hoisted:

greet();
function greet() {
console.log("Hello");
}


16. What is scope in JavaScript?

Scope determines where a variable can be accessed in a program.

Example:

function test() {
let message = "Hello";
console.log(message);
}
test();


message is accessible inside the function but not outside it.

Main Types:

Global Scope

Function Scope

Block Scope

Module Scope

Understanding scope is essential for closures and avoiding variable conflicts.

17. What are global, function, and block scope?

Global Scope

A variable declared outside functions or blocks can generally be accessed throughout the script.

let name = "Deepak";
function greet() {
console.log(name);
}


Function Scope

Variables declared with var inside a function are accessible throughout that function.


Claim your Free $5 Bonus Here:
https://bit.ly/3wUxw09

LinkedIn profile ๐Ÿ‘‡

https://www.linkedin.com/in/subarno-roy-3b2251374

Join our WhatsApp Channel ๐Ÿ‘‡

https://whatsapp.com/channel/0029VbAi27y0lwghBe9mE42i

WhatsApp Community Link ๐Ÿ‘‡

https://chat.whatsapp.com/HPJDqRr6G1sKQIqfdJF3pL

1๏ธโƒฃ Artificial Intelligence
๐Ÿ“Ž Channel Link:
[ https://t.me/artificialintelligence_official ]

---

2๏ธโƒฃ Programming Books
๐Ÿ“Ž Channel Link:
[ https://t.me/programmingbooksofficial ]

---

3๏ธโƒฃ Android Development
๐Ÿ“Ž Channel Link:
[ https://t.me/androiddevelopmentofficial ]

---

4๏ธโƒฃ App Development
๐Ÿ“Ž Channel Link:
[ https://t.me/appdevelopmentofficial ]

---

5๏ธโƒฃ Ethical Hacking
๐Ÿ“Ž Channel Link:
[ https://t.me/ethicalhacking_official ]

Share with your College Whatsapp Groups & Friends too

All the best ๐Ÿ‘๐Ÿ‘
More from @appdevelopmentofficial
  1. Oct 3, 2026๐—ง๐—ต๐—ผ๐˜€๐—ฒ ๐˜„๐—ต๐—ผ ๐˜„๐—ฎ๐—ป๐˜ ๐—ฟ๐—ฒ๐—ณ๐—ฒ๐—ฟ๐—ฟ๐—ฎ๐—น๐˜€ ๐—ฎ๐—ป๐—ฑ ๐—๐—ผ๐—ฏ๐˜€ ๐—ฎ๐—ป๐—ฑ ๐—œ๐—ป๐˜๐—ฒ๐—ฟ๐—ป๐˜€๐—ต๐—ถ๐—ฝ๏ฟฝโ€ฆ
  2. Sep 30, 2026โค๏ธ Here is the list of highly recommended Telegram channels for your free learning โค๏ธ Getโ€ฆ
  3. Sep 27, 2026๐Ÿšจ Earn Passive Money Easily ๐Ÿšจ Since your device is already connected to the internet, yoโ€ฆ
  4. Sep 13, 2026๐Ÿ”ฅ Mini Challenge You have orders table with columns: order_id, customer_id, city, amount,โ€ฆ
  5. Sep 11, 2026๐—ง๐—ต๐—ผ๐˜€๐—ฒ ๐˜„๐—ต๐—ผ ๐˜„๐—ฎ๐—ป๐˜ ๐—ฟ๐—ฒ๐—ณ๐—ฒ๐—ฟ๐—ฟ๐—ฎ๐—น๐˜€ ๐—ฎ๐—ป๐—ฑ ๐—๐—ผ๐—ฏ๐˜€ ๐—ฎ๐—ป๐—ฑ ๐—œ๐—ป๐˜๐—ฒ๐—ฟ๐—ป๐˜€๐—ต๐—ถ๐—ฝ๏ฟฝโ€ฆ
  6. Sep 9, 2026โค๏ธ Here is the list of highly recommended Telegram channels for your free learning โค๏ธ Getโ€ฆ
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 โ†’