An integer constant is a special case of the arithmetic constant. It's values must be integers - no decimal places.
It could be composed of several components if a constant expression is being created.
Integer constants can be defined as decimal, octal or hexadecimal values. Here are some examples:
Decimal notation - myVariable = 150
Hexadecimal notation - myVariable = 0xFF
Octal notation - myVariable = 0377
With a little creativity in the scripting, you can assign string constants to the value of string objects, then decode the character value to yield an integer constant:
myString = new String("A");
myVariable = myString.charCodeAt(0);
Prev | Home | Next |
Integer arithmetic | Up | Integer promotion |
JavaScript Programmer's Reference, Cliff Wootton Wrox Press (www.wrox.com) Join the Wrox JavaScript forum at p2p.wrox.com Please report problems to support@wrox.com © 2001 Wrox Press. All Rights Reserved. Terms and conditions. |