W3Schools JavaScript Web Programming Quiz

Reviewed by Editorial Team
The ProProfs editorial team is comprised of experienced subject matter experts. They've collectively created over 10,000 quizzes and lessons, serving over 100 million users. Our team includes in-house content moderators and subject matter experts, as well as a global network of rigorously trained contributors. All adhere to our comprehensive editorial guidelines, ensuring the delivery of high-quality content.
Learn about Our Editorial Process
| By Thames
T
Thames
Community Contributor
Quizzes Created: 11982 | Total Attempts: 187,298
| Questions: 20 | Updated: Aug 15, 2026
Please wait...
Question 1 / 21
🏆 Rank #-- ▾
0 %
0/100
Score 0/100

1. Which method removes the last element from an array?

Explanation

`pop()` removes and returns the last element of an array, reducing its length by one. By contrast, `shift()` removes the first element, `slice()` returns a portion without changing the original array, and `splice()` can add or remove elements at a specified position.

Submit
Please wait...
About This Quiz
W3Schools JavaScript Web Programming Quiz - Quiz

Test your JavaScript proficiency with this college-level quiz covering core web programming concepts. Explore variables, functions, DOM manipulation, asynchronous operations, and ES6+ features essential for modern web development. Perfect for students preparing for W3Schools certifications or advancing their JavaScript skills.

2.

What first name or nickname would you like us to use?

You may optionally provide this to label your report, leaderboard, or certificate.

2. What does Object.keys() return?

Explanation

`Object.keys()` returns an array containing an object’s own enumerable property names as strings. It lists the keys, not their associated values, and does not return a property count or a copy of the object. For example, `Object.keys({ name: "Ada" })` returns `["name"]`.

Submit

3. Which keyword is used to exit a loop prematurely?

Explanation

The `break` keyword immediately terminates the loop in which it appears, allowing the program to continue with the first statement after that loop. Unlike `return`, it does not exit the entire function.

Submit

4. What is the difference between '==' and '===' in JavaScript?

Explanation

In JavaScript, `==` performs type coercion before comparing, so values of different types may be considered equal. The strict equality operator `===` does not coerce types: both the value and the type must match for the comparison to be true.

Submit

5. Which method converts a string to an integer in JavaScript?

Explanation

`parseInt()` converts a string containing a number into an integer in JavaScript. For example, `parseInt("42")` returns the number `42`.

Submit

6. What is the purpose of the 'fetch' API?

Explanation

The `fetch` API is used to make HTTP requests from JavaScript, allowing a webpage to retrieve or send data to a server. It returns a Promise that can be handled to process the response.

Submit

7. Which CSS selector targets elements with a specific class?

Explanation

In CSS, a period (`.`) followed by a name selects elements whose `class` attribute includes that name. For example, `.classname` targets elements with `class="classname"`, while `#classname` targets an element by its ID.

Submit

8. What does the 'finally' block do in a try-catch statement?

Explanation

The `finally` block runs after the `try` and `catch` blocks, whether an error occurs or not. It is commonly used for cleanup tasks, such as closing files or releasing resources.

Submit

9. Which method is used to filter array elements?

Explanation

`filter()` tests each array element against a callback condition and returns a new array containing only the elements that pass. Unlike `map()`, it doesn’t transform every element; unlike `reduce()` and `forEach()`, its purpose is to select matching elements.

Submit

10. What is the correct syntax for a callback function in JavaScript?

Explanation

A callback is simply a function passed for later execution, so it can be written as a named function declaration, such as `function callback() {}`, or as a function-valued object property, such as `{ callback: function() {} }`. The second form is valid within an object literal.

Submit

11. Which keyword declares a block-scoped variable in JavaScript?

Explanation

`let` declares a variable whose scope is limited to the block, such as the statements inside `{}`. Unlike `var`, it does not create a function-scoped variable, and it can be reassigned after declaration.

Submit

12. What is the purpose of the spread operator (...) in JavaScript?

Explanation

The spread operator (`...`) expands an iterable, such as an array or string, into individual elements. It can be used to pass array values as function arguments, combine arrays, or copy their contents.

Submit

13. Which event fires when the DOM is fully loaded?

Explanation

`DOMContentLoaded` fires once the browser has finished parsing the HTML and built the DOM tree. It does not wait for images, stylesheets, or other external resources to finish loading; the `load` event waits for those as well.

Submit

14. What does JSON.stringify() convert?

Explanation

JSON.stringify() serializes a JavaScript value, such as an object, into a JSON-formatted string. This string can be stored, transmitted, or later parsed back into a JavaScript value.

Submit

15. Which method adds one or more elements to the end of an array?

Explanation

`push()` adds one or more elements to the end of an array and returns the array’s new length.

Submit

16. What is the output of typeof undefined?

Explanation

In JavaScript, the `typeof` operator returns a string describing a value’s type. When applied to `undefined`, it returns the string `"undefined"`.

Submit

17. Which of these is a valid way to create an arrow function?

Explanation

An arrow function requires parentheses for its parameter list, even when it takes no parameters, followed by `=>`. Here, `() => { return 5; }` is valid syntax and returns `5` when called.

Submit

18. What does the 'async' keyword do in a function declaration?

Explanation

An `async` function automatically returns a promise and allows `await` inside its body. However, `async` does not make the function run in parallel; asynchronous operations must be initiated separately. Therefore, “All of the above” is not technically accurate.

Submit

19. Which method is used to select an HTML element by its ID?

Explanation

`getElementById()` is a Document Object Model (DOM) method that retrieves the HTML element whose `id` attribute matches the supplied value. For example, `document.getElementById("header")` selects the element with `id="header"`.

Submit

20. What is the primary purpose of the 'this' keyword in JavaScript?

Explanation

In JavaScript, `this` refers to the context in which a function is called. When used inside an object’s method, it typically points to that object, allowing the method to access its properties and other methods. Its value can vary depending on how the function is invoked.

Submit
×
Saved
Thank you for your feedback!
View My Results
Cancel
  • All
    All (20)
  • Unanswered
    Unanswered ()
  • Answered
    Answered ()
Which method removes the last element from an array?
What does Object.keys() return?
Which keyword is used to exit a loop prematurely?
What is the difference between '==' and '===' in JavaScript?
Which method converts a string to an integer in JavaScript?
What is the purpose of the 'fetch' API?
Which CSS selector targets elements with a specific class?
What does the 'finally' block do in a try-catch statement?
Which method is used to filter array elements?
What is the correct syntax for a callback function in JavaScript?
Which keyword declares a block-scoped variable in JavaScript?
What is the purpose of the spread operator (...) in JavaScript?
Which event fires when the DOM is fully loaded?
What does JSON.stringify() convert?
Which method adds one or more elements to the end of an array?
What is the output of typeof undefined?
Which of these is a valid way to create an arrow function?
What does the 'async' keyword do in a function declaration?
Which method is used to select an HTML element by its ID?
What is the primary purpose of the 'this' keyword in JavaScript?
play-Mute sad happy unanswered_answer up-hover down-hover success oval cancel Check box square blue
Alert!