Cognizant GenC 2025
TOP - 20 JavaScript
Interview
Question
With
Answers
By- Shubham Maurya
[Link]
[Link]
Cognizant GenC
[Link]
[Link]
[Link]
Q1. What is JavaScript?
JavaScript is a scripting language used to make web pages interactive. Runs in browser +
[Link]
2. Difference between Java & JavaScript?
Totally different languages
Java → OOP, compiled
JavaScript → Scripting, interpreted
Q3. var vs let vs const?
var → function scoped
let → block scoped
const → cannot be reassigned
var a = 10;
let b = 20;
const c = 30;
Q4. What is DOM?
Document Object Model – structure of the webpage JavaScript can access & modify.
Q5. What is Hoisting?
JavaScript moves declarations to top during execution.
Q6. Data types in JavaScript?
Primitive: string, number, boolean, null, undefined, bigint, symbol
Non-Primitive: object, array, function
Q7. What is == vs === ?
== → compares value
=== → compares value + type
2 == "2" // true
2 === "2" // false
Q8. What is a Function?
Reusable block of code.
Q9. Types of functions?
Normal function
Arrow function
Anonymous function
function add(a,b){ return a+b; }
const addArrow = (a,b) => a+b;
Q10. Common Array Methods?
map(), filter(), reduce(), push(), pop()
let arr = [1,2,3];
[Link](x => x*2);
Q11. What is JSON?
JavaScript Object Notation – used to exchange data.
Q12. What is synchronous vs asynchronous?
Sync → executes line by line
Async → doesn’t block ow (fetch, setTimeout)
Q13. What is Callback, Promise & async-await?
Callback → function inside function
Promise → future value
async-await → cleaner async code
async function getData(){
let res = await fetch(url);
}
Q14. What is Event Loop?
Handles async operations in JS.
Q15. What is Closure?
Function + Lexical scope together.
fl
Q16. What is this keyword?
Refers to current execution context.
Q17. How to select HTML elements?
[Link]()
[Link]()
Q18. Event handling?
[Link]("click", function(){})
Q19. Reverse a string
[Link]("hello".split('').reverse().join(''));
Q20. Find largest number in array
[Link](...arr)