
JavaScript is the backbone of modern web development. For ECET 2026 Web section, questions often focus on syntax, variables, operators, data types, and functions. These are easy scoring areas if you practice them with examples.
📘 Concept Notes
🔑 What is JavaScript?
- JavaScript (JS) is a scripting language used to make web pages interactive.
- Runs directly in browsers (client-side).
- Supports object-oriented, functional, and event-driven programming.
⚙️ Basic Syntax Rules
- Case Sensitive:
myVar
andmyvar
are different.
- Statements End with Semicolon:
let a = 10;
console.log(a);
- Comments:
// Single-line comment
/* Multi-line
comment */
📂 Variables in JavaScript
- Declared using:
var x = 5; // function-scoped let y = 10; // block-scoped const z = 20; // constant
📐 Data Types
- Primitive:
Number
,String
,Boolean
,Undefined
,Null
,Symbol
,BigInt
- Non-Primitive:
Object
,Array
,Function
🧮 Operators
- Arithmetic:
+
,-
,*
,/
,%
- Assignment:
=
,+=
,-=
- Comparison:
==
,===
,!=
,<
,>
- Logical:
&&
,||
,!
📘 Functions
function add(a, b) {
return a + b;
}
console.log(add(2, 3)); // Output: 5
Arrow Functions:
const multiply = (x, y) => x * y;<br>
📊 Example Program
let name = "ECET Student";
let marks = 90;
if (marks >= 50) {
console.log(name + " passed the exam!");
} else {
console.log(name + " failed.");
}
Output:
ECET Student passed the exam!
🔟 10 Expected MCQs – ECET 2026
Q1. JavaScript is:
A) Compiled language
B) Interpreted scripting language
C) Assembly language
D) Machine language
Q2. Which keyword declares a block-scoped variable?
A) var
B) let
C) const
D) both B & C
Q3. In JavaScript, ===
operator checks:
A) Only value
B) Only type
C) Value and type
D) None
Q4. Which is a valid comment in JavaScript?
A) # comment
B) // comment
C) <!-- comment -->
D) ** comment **
Q5. What is the output of console.log(2 + "2")
?
A) 4
B) 22
C) Error
D) Undefined
Q6. Which function syntax is correct?
A) def add(x,y)
B) function add(x,y)
C) func add(x,y)
D) fn add(x,y)
Q7. Which data type is NOT primitive?
A) Number
B) Array
C) String
D) Boolean
Q8. What does const
mean?
A) Variable can’t change
B) Variable can change
C) Function declaration
D) Scope keyword
Q9. Which operator is logical AND in JavaScript?
A) &
B) &&
C) and
D) ||
Q10. Which statement is true?
A) JS runs only on server
B) JS runs only on browser
C) JS runs both in browser and server
D) JS is not portable
✅ Answer Key
Q.No | Answer |
---|---|
Q1 | B |
Q2 | D |
Q3 | C |
Q4 | B |
Q5 | B |
Q6 | B |
Q7 | B |
Q8 | A |
Q9 | B |
Q10 | C |
🧠 Explanations
- Q1 → B: JS is an interpreted scripting language.
- Q2 → D: Both
let
andconst
are block-scoped. - Q3 → C:
===
checks both type and value. - Q4 → B:
// comment
is valid. - Q5 → B: Number + string → concatenation →
"22"
. - Q6 → B: Functions use
function
keyword. - Q7 → B: Arrays are objects (non-primitive).
- Q8 → A:
const
means the reference cannot change. - Q9 → B: Logical AND =
&&
. - Q10 → C: JS can run in browsers and servers (Node.js).
🎯 Why Practice Matters
- JS basics form the foundation of DOM, events, AJAX, and frameworks (React, Angular).
- ECET questions are mostly direct and concept-based.
- Mastering syntax = quick scoring.