1️⃣ Data Types
Concept to write in pen-paper test:
JavaScript has primitive types: Number, String, Boolean, Undefined, Null, Symbol, BigInt
Non-primitive (Reference): Object, Array, Function
Example (if asked):
let name = "Sakthi"; // String
let age = 21; // Number
let isStudent = true; // Boolean
2️⃣ Variable Declarations
var: Function-scoped, hoisted
let: Block-scoped, not hoisted in temporal dead zone
const: Block-scoped, cannot reassign
Pen-paper format:
var x = 5; // can redeclare, function scoped
let y = 10; // cannot redeclare, block scoped
const z = 20; // constant, block scoped
Perfect! Let me explain Hoisting and Operators in a way you can directly write in your pen & paper
test for VisAI Lab. I’ll make it concise, clear, and exam-ready.
3️⃣ HOISTING
Definition (write in 1–2 lines):
Hoisting is a JavaScript behavior where variable and function declarations are moved to the top of
their scope before code execution.
Key Points (write as bullets):
Variables declared with var are hoisted, let and const are not hoisted in the temporal dead
zone.
Functions are hoisted entirely, so they can be called before their declaration.
Example (write in pen-paper format):
[Link](a); // undefined
var a = 10;
[Link](b); // ReferenceError
let b = 20;
function test(){
[Link]("Hello");
test(); // Hello
Explanation (write 1 line):
a is hoisted, so output is undefined. b is not hoisted. Functions are hoisted, so test() works before
definition.
4️⃣ OPERATORS
Definition (write in 1–2 lines):
Operators are symbols used to perform operations on values or variables.
Types & Examples (write as bullets):
1. Arithmetic Operators: + - * / % ++ --
let x = 5;
x++; // 6
5 + 3 // 8
2. Comparison Operators: ==, ===, !=, !==, >, <
5 == "5" // true (only value compared)
5 === "5" // false (value + type compared)
3. Logical Operators: &&, ||, !
true && false // false
true || false // true
!true // false
Common trap (write as note):
== checks value only, === checks value + type
5️⃣ Functions
Normal function:
function add(a,b){ return a+b; }
Arrow function:
const add = (a,b) => a+b;
Difference: this keyword behaves differently
1️⃣ Difference between == and === (2 Marks)
== compares only the value and performs type conversion.
=== compares both value and data type without type conversion.
Example:
5 == "5" // true
5 === "5" // false
2️⃣ Difference between var, let, and const (2 Marks)
var is function scoped and can be redeclared.
let is block scoped and cannot be redeclared.
const is block scoped and its value cannot be reassigned.
3️⃣ Difference between map() and forEach() (2 Marks)
map() returns a new array after applying a function.
forEach() does not return a new array; it is used for iteration only.
Example:
[Link](x => x*2); // returns new array
[Link](x => x*2); // no return
4️⃣ Explain this in JavaScript (2 Marks)
this refers to the object that is calling the function.
Its value depends on how the function is invoked.
Example:
let obj = {
name: "JS",
show() {
[Link]([Link]);
};
5️⃣ Difference between Function Declaration and Function Expression (2 Marks)
Function declaration is hoisted and can be called before definition.
Function expression is not hoisted and cannot be called before assignment.
Example:
function add(a,b){} // declaration
const add = function(a,b){} // expression
1️⃣3️⃣ DOM Basics (Pen-paper style)
Only conceptual questions may appear
[Link]("id");
[Link](".class");
[Link] = "Hello";
1️⃣4️⃣ Event Handling (Conceptual)
onclick, onchange, onsubmit
Example answer:
<button onclick="alert('Hi')">Click</button>
6️⃣ Arrays
Array creation:
let arr = [1,2,3,4];
Common methods:
push() – add element
pop() – remove last
shift() – remove first
unshift() – add first
map(), filter(), reduce() – functional
Pen-paper format:
[Link](5); // arr = [1,2,3,4,5]
map()
👉 What it does
Transforms each element
Returns a new array
👉 Example
let nums = [1, 2, 3];
let result = [Link](n => n * 2);
[Link](result);
✅ Output: [2, 4, 6]
Interview line:
map() is used when we want to transform array elements.
5️⃣ filter()
👉 What it does
Filters elements based on a condition
Returns a new array
👉 Example
let nums = [1, 2, 3, 4];
let result = [Link](n => n % 2 === 0);
[Link](result);
✅ Output: [2, 4]
Interview line:
filter() returns elements that satisfy a condition.
6️⃣ reduce()
👉 What it does
Reduces array to a single value
Uses an accumulator
👉 Example (sum)
let nums = [1, 2, 3, 4];
let sum = [Link]((acc, curr) => acc + curr, 0);
[Link](sum);
✅ Output: 10
Method Purpose Output
map() Transform New array
filter() Select New array
reduce() Combine Single value
🧠 ONE-LINE MEMORY TRICK
map → change
filter → select
reduce → combine
7️⃣ Objects
Key-value pairs
let person = {name:"Sakthi", age:21};
[Link]([Link]); // Sakthi
Can be nested
8️⃣ String Methods
length, charAt(), toUpperCase(), toLowerCase(), slice(), substring()
Example:
let str = "FullStack";
[Link](); // "FULLSTACK"
9️⃣ Template Literals
Use backticks ` and ${} for dynamic strings
let name = "Sakthi";
[Link](`Hello, ${name}`); // Hello, Sakthi
🔹 Coding Problems (Most Likely)
Reverse a string / number
Check palindrome / anagram
Find largest / smallest element in array
Simple factorial / fibonacci
Small pattern printing