Course Hero Logo
This textbook is available Logo
JavaScript: The Web Warrior Series 6th Edition

JavaScript: The Web Warrior Series (6th Edition)

Book Edition6th Edition
SubjectComputer Science
Chapter 3, Storing Data in Arrays, Short Quiz, Exercise 1
Page 162

How is an array different from a standard variable?

Sample Response

ArrayStandard Variable
An array is a group of homogenous types of values that are stored in contiguous memory locations. A variable stores a single value and its memory size depend on the data-type of that variable.
An array can store multiple values at a time.A standard variable can store only a single value at a time. 

The syntax to create an array in JavaScript is mentioned below. 

var array_name = [n1, n2, n3,...];

where n1, n2, n3  are the elements of the array. 

The syntax to create a variable in JavaScript is mentioned below.

var variable_name;

How would you rate this answer and explanation?
Did you like this example?
Subscribe for full access
Page 162