Primitive data types
Variables that have primitive data types pass their data by value, by actually copying the data to the new location. The following fragment illustrates:
var a = "abc";
var b = ReturnValue(a);
function ReturnValue(c)
{
return c;
}
After "abc" is assigned to variable a, two copies of the string "abc" exist, the original literal and the copy in the variable a. While the function ReturnValue is active, the parameter/variable c has a copy, and three copies of the string "abc" exist. If c were to be changed in such a function, variable a, which was passed as an argument to the function, would remain unchanged. After the function ReturnValue is finished, a copy of "abc" is in the variable b, but the copy in the variable c in the function is gone because the function is finished. During the execution of the fragment, as many as three copies of "abc" exist at one time.
The primitive data types are: Number, Boolean, and String.