JavaScript is a popular programming language. What is its main use?
Think about what happens when you click buttons or see animations on websites.
JavaScript runs in the browser to make web pages interactive, like responding to clicks or updating content without reloading.
Look at this code and choose the correct output.
console.log(typeof []);
In JavaScript, arrays are a type of object.
The typeof operator returns "object" for arrays because arrays are special objects in JavaScript.
What will this code print to the console?
console.log(0.1 + 0.2 === 0.3);
Think about how computers handle decimal numbers.
Due to floating-point precision, 0.1 + 0.2 is not exactly 0.3, so the comparison is false.
Choose the correct statement about JavaScript.
Think about how JavaScript handles tasks like fetching data from the internet.
JavaScript supports asynchronous programming using promises and async/await to handle tasks without blocking the program.
What will this code print to the console?
function makeCounter() { let count = 0; return function() { count += 1; return count; }; } const counter1 = makeCounter(); const counter2 = makeCounter(); console.log(counter1()); console.log(counter1()); console.log(counter2());
Each call to makeCounter creates a new independent counter.
counter1 and counter2 have separate count variables. counter1 increments twice, then counter2 starts at 0 and increments once.