You are debugging a piece of code and encounter a variable declaration let [a, b, ...rest] = [10, 20, 30, 40, 50];. What will be the value of rest?
- [30, 40, 50]
- [10, 20]
- [20, 30, 40, 50]
- [undefined, undefined]
The value of rest will be [30, 40, 50]. This code uses destructuring assignment to assign the first two elements to a and b, and the rest of the elements to rest using the rest parameter (...). So, a will be 10, b will be 20, and rest will contain [30, 40, 50].
Loading...
Related Quiz
- You are debugging a web application and notice that a "for" loop is causing the webpage to hang. What could be a potential reason and how might you solve it?
- A ________ object represents a group of response headers, allowing you to query them and take different actions depending on the results.
- If you’re using arrow functions to define methods inside a class, those methods will not have access to the class’s instance without using _________.
- What is the primary difference between while and do-while loops in JavaScript?
- In JavaScript, a common way to utilize prototypes is by assigning a(n) _________ to an object's prototype property.