HTML QUESTIONS
Question 1: What are the new features of HTML5?
HTML5 adds video, audio, canvas, new tags, and offline storage.
Question 2: What is the purpose of the doctype declaration in HTML5?
It tells the browser which version of HTML is used.
Question 3: What would happen if I would not declare doctype in HTML?
The page may not display correctly in browsers.
Question 4: What are data attributes in HTML5 and how are they used?
They store custom data in elements using data-* attributes.
Question 5: What is the difference between HTML and HTML5?
HTML5 supports multimedia, APIs, and new structure tags.
Question 6: Difference between SVG and Canvas?
SVG uses shapes (vector), Canvas uses pixels (raster).
Question 7: What is the difference between localStorage, sessionStorage, and cookies?
LocalStorage saves forever, SessionStorage till tab closes, Cookies send with requests.
Question 8: What are the void elements in HTML?
Elements without closing tags like <img>, <br>, <hr>, <input>.
Question 9: What is BOM (Browser Object Model) and what is the root object in it?
BOM controls the browser window; root object is window.
Question 10: What are the various formatting tags in HTML?
b, i, u, strong, em, mark etc.
Question 11: In how many ways you can display HTML elements?
Inline, block, inline-block, flex, grid, none.
Question 12: What is the difference between a tag and an attribute?
Tag builds structure; attribute gives extra details.
Question 13: What are data attributes in HTML5 and how are they used?
They hold custom data for JavaScript using data-*.
Question 14: What are different types of list in HTML?
Ordered list, unordered list, and description list.
CSS QUESTIONS
Question 1: Explain CSS position properties?
They define placement as static, relative, absolute, fixed, or sticky.
Question 2: What is the difference between display inline, inline-block, and block?
Inline = same line, Block = full width, Inline-block = both mix.
Question 3: What are the different types of selectors in CSS?
Element, class, ID, attribute, pseudo, and universal.
Question 4: What are pseudo elements and pseudo classes?
Pseudo-classes style element states; pseudo-elements style parts of elements.
Question 5: What are new features in CSS3?
Flexbox, grid, animation, shadow, and rounded corners.
Question 6: What is the box model in CSS3?
It includes content, padding, border, and margin.
Question 7: In how many ways can we add CSS to our HTML file?
Inline, internal, and external stylesheets.
JAVASCRIPT QUESTIONS
Question 1: What are the data types in JavaScript?
String, Number, Boolean, Object, Undefined, Null, Symbol, BigInt.
Question 2: What is an object in JavaScript?
It’s a collection of key-value pairs.
Question 3: In how many ways we can define an object in JavaScript?
By literal, constructor, class, or new Object().
Question 4: How to define a class in JavaScript?
Using class ClassName { constructor(){} }.
Question 5: What is defineProperty() method of JavaScript Object?
It adds or changes a property in an object.
Question 6: What is scope in JavaScript?
It defines where variables can be used.
Question 7: Explain variable hoisting?
JS moves declarations to the top before running code.
Question 8: Explain closures in JavaScript?
A function that remembers outer variables after the outer function ends.
Question 9: Difference between null and undefined?
Null = empty value, Undefined = not assigned.
Question 10: Difference between == and ===?
== checks value, === checks value and type.
Question 11: What are the new features in ES6?
let/const, arrow functions, classes, promises, modules.
Question 12: Explain time complexity?
It shows how execution time grows with input size.
Question 13: What is space complexity?
It shows how memory use grows with input size.
Question 14: Explain call(), bind(), and apply() in JavaScript?
They call functions with a specific this value.
Question 15: Advantage of using arrow functions?
They are short and keep parent this value.
Question 16: What is webpack and babel?
Webpack bundles files; Babel converts new JS to old JS.
Question 17: How can we add an element at the start of a JavaScript array?
Use [Link](item).
Question 18: How to capitalise all the first letters of a given string?
Use [Link](/\b\w/g, c => [Link]()).
Question 19: Difference between pass by value and pass by reference?
Value = copy made; Reference = same memory used.
Question 20: What is InstanceOf operator?
Checks if an object belongs to a class.
Question 21: What is the use of constructor() in a class?
It sets values when making new objects.
Question 22: How can we use JavaScript Set to remove duplicate elements of an array?
Use [Link](new Set(arr)).
Question 23: What is the data storage limit of a cookie and max characters?
About 4KB and around 20 cookies per domain.
Question 24: How to make deep copy and shallow copy of objects?
Deep copy = full clone; Shallow copy = top-level only.
Question 25: What’s the difference between for loop and forEach loop?
for can break early; forEach cannot.
Question 26: What is a unary function?
A function that takes only one argument.
Question 27: What is JSON in JavaScript and its advantages?
JSON stores and transfers data in simple text format.
Question 28: What is [Link]()?
It converts an object to a JSON string.
Question 29: What is [Link]()?
It converts a JSON string back to an object.
CODE OUTPUT QUESTIONS
Question 1
Output → undefined (variable a is hoisted but not set).
Question 2
Output → 5 5 5 5 5 (because var is not block scoped).
Question 3
Output → undefined, then 10 (this inside x() is global).
Question 4
Output → Error, '4.2', NaN.
Question 5
Output → 0 1 2 3 4 (IIFE keeps each value).