Simple Variables

By: Dusty Arlia
Published on September 11, 2012
Last Updated on Wednesday, July 15, 2015 at 1:27 PM
Total Updates: 4

A simple variable is a variable that can be referred to by its name alone. For example:

var fullName = 'Dusty Arlia';

This is a simple string variable. You know it is a simple variable because you can access it by referencing its name: fullName. Here is an example of how you can reference a simple variable by name:

document.write('<h1>Hello ' + fullName + '!</h1>');

An example of a variable which is not considered a simple variable would an array. Arrays store multiple values and accessing one of its values cannot be done by referencing its name alone.

Here is an example of an array:

var fullNames = ['Dusty Arlia',
                 'Justin Bieber',
                 'Emma Watson',
                 'Kim Kardashian',
                 'Kanye West',
                ];

You couldn't reference a value in an array by just using the array's name: fullNames. For this reason, arrays are not simple variables.

Comments:

Ad: