back to course
Lesson 114 / 11599%· free preview
Exam Prep1/2
JavaScript Exam Questions
JS theory + programs + ES6 + DOM — full exam preparation.
Overview
Most-asked JavaScript exam questions for BCA, B.Tech, and campus interviews.
1. Theory Questions
- What is JavaScript? A high-level, interpreted, multi-paradigm scripting language for web pages. Created by Brendan Eich in 1995.
- Where does JS run? In any JavaScript engine — V8 (Chrome, Node.js), SpiderMonkey (Firefox), JavaScriptCore (Safari).
- Is JS compiled or interpreted? Modern engines do JIT compilation (just-in-time) — compile hot code to machine code on the fly.
var,let,const?var— function-scoped, hoisted, can be re-declared.let— block-scoped, NOT hoisted to top.const— block-scoped, immutable binding (object contents are still mutable).
==vs===?==does type coercion (5 == '5'→ true).===strict (no coercion).
2. Common Programs / WAP
- WAP to find sum of digits of a number.
- WAP to reverse a string without
reverse(). - WAP to find max in array using loop.
- WAP using
addEventListenerto alert on button click. - WAP to validate a form (empty fields, email pattern).
3. Predict-the-output (very common)
jsconsole.log(typeof null); // 'object' console.log(typeof undefined); // 'undefined' console.log([] + []); // '' (empty string) console.log([] + {}); // '[object Object]' console.log(0.1 + 0.2 === 0.3); // false (floating-point)
4. ES6 Features (always asked)
let/const- Arrow functions:
(a, b) => a + b - Template literals:
`Hello ${name}` - Destructuring:
const { a, b } = obj; - Spread/rest:
[...arr],(...args) => … - Promises +
async/await - Classes:
class Foo { constructor() {} } - Modules:
import x from 'y'
5. DOM Section
- DOM = Document Object Model — tree of HTML elements as JS objects.
document.getElementById("x"),document.querySelector(".btn").- Event listeners:
el.addEventListener("click", fn). innerHTML(parses HTML) vstextContent(treats as text).
6. Pro Tips
- Always use
===in production — avoids coercion bugs. - Default to
const, fall back toletonly when reassigning. - Use
async/awaitinstead of nested.then()for readable async code. - Mention event bubbling when discussing event handlers — high-mark answer.
AI-powered recap
Quick recap quiz?
We'll generate 5 MCQs from this lesson and check your understanding instantly. Takes ~30 seconds.
# program
Program
JavaScript
// Quick demo: arrow + map + destructure
const nums = [1, 2, 3, 4];
const doubled = nums.map(n => n * 2);
const [first, ...rest] = doubled;
console.log(first, rest); // 2 [4, 6, 8]Ready to move on?
// example library
Want more hands-on snippets in JavaScript?
Browse 2 runnable examples · across 1 chapter · short, copy-paste-friendly · grouped by topic
// deep-dive
Go deeper — hand-picked articles
Long-form guides, shortcuts, and mental models that won't fit in a single lesson.
// feedback.matters()
Did this lesson help you?
