Strings versus Variables
The following sets the string value to the "foo" property:
item = { "name" : "foo" } // item.name = "foo"
Next, the variable value is assigned foo . If the variable foodoes not exist, you will receive an error message:
item = { "name" : foo } // foo doesn't exist yet, will result in error
foo = "my value" // foo is defined here
item = { "name" : foo } // item.name = "my value"
Numbers versus Strings
Next, the property is assigned : Number
child = { "age" : 3 } // child.age = 3
Numbers can be used in all mathematical operations. For example, child.age * 3lead to 9, and child.age + 4lead to 7.
string:
child = { "age" : "3" } // child.age = "3"
. , child.age * 3 9, , child.age + 4 34 - .
, . , ( ).