Q. What is the correct way to write a JavaScript array?

A
var colors = (1: red, 2: blue)
B
var colors = [red, blue]
C
var colors = 'red', 'blue'
D
var colors = {red, blue}
Solution:

Arrays in JavaScript are defined with square brackets, e.g., var colors = [‘red’, ‘blue’].

Entri PDF Icon

Get Question Bank

Strengthen Your Practice with our comprehensive question bank.

Entri Contact Image

Get Expert Advice for Free: Register for Your Free Consultation Now!