www.crosswinds.net/~fishcaro/day_J3_data_types.htm
INDEX CARD #J3:
DATA TYPES IN JAVASCRIPT (J3a)
|
LITERALS (J3b)
|
IDENTIFIERS (J3c)RULES FOR LEGAL IDENTIFIER NAMES:
|
OBJECT DATA TYPE (J3d)More precisely, an object is a collection of named pieces of data; the named values are usually referred to as properties of the object. We also need tools to work with the objects: these tools (functions) are called the methods of the object. To refer to a property of an object, you put the object name, followed by a period, followed by the property name.
For example, if an object named image.width write() method (function) of
the document object, you would write:
document.write("Hello there!"); |
NUMBERS (J3e)
|
CONVERTING A NUMBER TO A STRING (J3f)toString() method is used to convert a number to a string.
The argument of toString() (that is, the number inside the
parentheses) gives the base of the desired output.
For example: The value of y is 12 Note: This result is NOT a number; it is a STRING! Shorthand notation (the number MUST be in parentheses): y = (10).toString(8);
|
Printable version of Index Card J3a
Printable version of Index Card J3b
Printable version of Index Card J3c
Printable version of Index Card J3d
Printable version of Index Card J3e
Printable version of Index Card J3f
WORKSHEET #J3:
x
given below, to explore numbers and strings:
x = 5; document.write("The value of x is " + x + "<BR>");
x
as either a number or a string.
x
is a NUMBER.)
x
that you'll be using:
x = 0x10;
x = 0X10;
x = 12;
x = "12";
x = '12';
x = 12+1;
x = "12" + "1";
x = 3e2;
x = 3e50;
x = 3e-2;
x = (10).toString(8);
x = (10).toString(3);
x = (100).toString(16);
http://www.snap.com
when it is clicked.