1. What is JavaScript?
JavaScript is a high-level, interpreted programming language primarily used to add
interactivity and dynamic behavior to web pages. It runs in the browser (client-side) and
can also run on the server (e.g., [Link]). JavaScript is: Dynamically typed – variable
types are determined at runtime. Prototype-based – uses prototypes for inheritance
rather than classical classes (though class syntax exists as syntactic sugar). Event-driven
and asynchronous-friendly – supports callbacks, promises, and async/await for handling
asynchronous operations. Common uses: Manipulating the DOM (update page
content/styles) Handling user events (clicks, form submissions) Fetching data from servers
(AJAX / Fetch API) Building full-stack apps with frameworks (React, Vue, Angular) and
[Link] on the backend
2. What are the data types in JavaScript?
JavaScript has two main kinds of data types: Primitive types and Non-primitive
(reference) types.
Primitive Data Types
These store single values and are immutable (cannot be changed).
Examples: String – "Hello" (sequence of characters) Number – 42, 3.14 (represents
integers and floating-point numbers) Boolean – true, false (logical values) Undefined – a
variable declared but not assigned a value Null – represents an intentional empty value
Symbol – Symbol("id") (unique and immutable value, often used as object keys) BigInt –
123n (used for very large integers beyond Number limits) Non-Primitive (Reference)
Data Types
These store collections or objects.
Examples: Object – {name: "Darshan", age: 21} Array – [1, 2, 3] Function – function
greet(){} Example Code:
let name = "Darshan"; // String let age = 21; // Number let isStudent = true; // Boolean let x;
// Undefined let y = null; // Null let big = 123n; // BigInt let person = {name: "DC"}; // Object