Which of the following is the correct syntax for destructuring an array in JavaScript?
- let [x, y] = [1, 2];
- let {x, y} = [1, 2];
- let (x, y) = [1, 2];
- let x = [1, 2];
Destructuring an array in JavaScript is done using square brackets []. The correct syntax is let [x, y] = [1, 2];. The other options are either for object destructuring or use incorrect syntax.
Loading...
Related Quiz
- Named imports in JavaScript must match the exported names in the module, unless they are ________.
- How can you ensure that your project’s dependencies are secure and up-to-date?
- You are tasked with optimizing a Node.js application suffering from frequent delays and unresponsive behavior. How would you diagnose and address potential issues related to the Event Loop and blocking operations?
- To handle uncaught exceptions in a Node.js application, you can use process.on('______', callback).
- The ______ command can be used to update the package.json file to match the actual versions installed in the node_modules directory.