A.2. Variables
Variables in ECMAScript are declared using the var keyword. Variable names must begin with a letter or an underscore followed by zero or more letters, numbers, and underscores. ECMAScript variables are case-sensitive.
ECMAScript supports weak typing. The programmer does not need to specify the type of a variable when declaring it; the interpreter automatically associates one of the five built-in ECMAScript types with the new variable based on the nature of the value assigned to it. These built-in types are shown in Table A-2.
Type | Description | Examples |
---|---|---|
number | either a floating-point or integer |
var e = 2.71828; var i = -1; |
Boolean | only true or false |
var b = true; |
string | a string of characters |
var ... |
Get Definitive VoiceXML™ now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.