Declarations


Declaring variables within JScript is pretty easy using a simple VAR statement with the name of the variable you want to declare. For example, to declare a variable called invoice_total, your declaration statement would look like this:

var invoice_total;

The name and case of your variable is important and is one of the main errors you will encounter when working with JScript. You can name variables using a mix of alphanumeric characters, underscores, and dollar signs, but the variable name has to begin with a letter, underscore, or dollar sign. In addition, you can’t name a variable the same name as a reserved word (a list of reserved words in JScript is provided near the end of this appendix).

When working with variables, six different types can be associated with a variable:

  • number

  • string

  • object

  • Boolean

  • null

  • undefined

When a variable is first created and unassigned (in other words, there is no value assigned to it) it is considered to be undefined:

var sales_tax;

When an assignment is made to the variable, it then takes the type of the value assigned. For example:

var sales_tax = 10;   //Number
var sales_tax = "Not applicable"; //String




How to Do Everything with Microsoft Office InfoPath 2003
How to Do Everything with Microsoft Office InfoPath 2003 (How to Do Everything)
ISBN: 0072231270
EAN: 2147483647
Year: 2006
Pages: 142

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net