Data Types
JavaScript support three primitive data types:
- Boolean - true, false
- Number - all numbers
- Integers
- Hex and Octal
- Floating Point
- String - typically quoted
JavaScript also supports two composite data types:
- Object
- Arrays (of numbers, strings, Boolean, objects)
In addition JavaScript supports two trivial data types:
- Null
- Undefined
Functions in JavaScript may be used to return data.
JavaScript is a weakly typed language in that ALL variables are not
declared as a specific data type.
Functions
JavaScript has two types of functions:
- User-defined - created by the user (can include a unique name,
input parameters, and returned data).
- Built-in - including the following:
 | Escape - encodes the string that is contained in the string
argument to make it portable (a string is considered portable if it can be
transmitted across any network to any computer that supports ASCII
characters). To make a string portable, characters other than the
following 69 ASCII characters must be encoded:
ABCDEFGHIJKLMNOPQRSTUVWXYZ
abcdefghijklmnopqrstuvwxyz
1234567890
@*-_+./
All other characters are converted either to their two digit (%xx) or four
digit (%uxxxx) hexadecimal equivalent.
|
 | Eval - evaluates and/or executes a string of JavaScript code. |
 | isFinite - used to determine if an argument is a finite and legal
number. |
 | isNaN - used to determine if an argument is a NaN. |
 | Number - converts the object argument to a string
representing the object's value, if the value cannot be represented by a
legitimate number, the "Not-a-Number" value, NaN is
returned. |
 | parseFloat - determines if the first character in the string
argument is a number, parses the string from left to right until it reaches
the end of the number, discards any characters that occur after the end of
the number, and finally returns the number as a number (not as a string). |
 | parseInt - find the first integer in a string. There are two
arguments. The mandatory string argument is the string which is
presumed to contain an integer. The optional radix argument specifies
the base of the integer and can range from 2 to 36. For example, 16 is the
hexidecimal base (0123456789ABCDEF). |
 | String - converts the object argument to a string
representing the object's value. |
 | Unescape - decodes an encoded string argument that was
created using the escape function |
Objects
Many of these are/can be named objects (you can define a local name,
e.g., var mystring = "hello world", mystring is a string object).
 | Anchor - target of a hyperlink |
 | Applet - embedded applet in a web page (often Java) |
 | Area - same as a link |
 | Array - built-in support for arrays, includes length property; also
includes concat, join, pop and other methods. |
 | Boolean - support for boolean values |
 | Button - graphic pushbutton |
 | Checkbox - graphic checkbox |
 | Date - manipulate date and time values |
 | Document - HTML document window management, numerous properties for
document objects (links, forms, etc.); includes write method for output to
browser window |
 | Event - details about an event |
 | FileUpload - file upload for form input |
 | Form - HTML input form (typically superior to form objects) |
 | Frame - type of window object |
 | Function - a JavaScript function |
 | Hidden - hidden data field access |
 | History - URL history of the browser |
 | Image - image in a web browser document |
 | Layer - independent layer in a DHTML document
|
 | Link - hypertext link |
 | Location - represents and controls browser location (current URL, host
port, and protocol information) |
 | Math - manages mathematical functions (absolute value, trig functions,
random, round, etc.) and constants (.E, .LN10, .PI, etc.) . |
 | Navigator - information about the current browser (type, platform, etc.). |
 | Number - support for numbers (convert to string, is a number). |
 | Object - superclass that contains features of all JavaScript objects. |
 | Option - an option in a select box. |
 | Password - specialized input box. |
 | Radio - graphical radio button. |
 | Reset - graphical button for resetting a form. |
 | Screen - provides information about the display. |
 | Select - a graphical selection list. |
 | String - support for strings include replace, search, concatenation, and
other manipulation methods. |
 | Submit - graphical button for triggering a form submission. |
 | Text - graphical text input field. |
 | Textarea - graphical multi-line text input area. |
 | Window - web browser window or frame.
|
Operators
 | Arithmetic
=
+, ++
-, --
/
% |
 | Assignment
= |
 | Backslash Escaped Characters
\'
\"
\\
\b
\f
\n (newline)
\r
\t |
 |
Bitwise
&
|
^
~
<<
>>
>>> |
 | Comparison
==
!=
===
!==
>
>=
<
<= |
 |
Logical
&& (and)
|| (or)
! (not) |
 | Special
?:
'
delete
new
this
typeof
void |
 | String
+ (concatenate)
|
Statements
 | Break - used to terminate a current loop, switch or label
statement and pass control to the statement immediately following it |
 | Comment - programmer notes, they are ignored by the JavaScript
interpreter |
 | Continue - restarts a while, do...while, for
or label statement, in a while loop it jumps back to the
condition. |
 | Do...While - executes one or more statements at least once,
checking that a certain condition is met each time before repeating. If
that condition is not met, then control moves to the statement immediately
after the loop. |
 | Export - allows a signed script to provide properties, functions
and objects to other signed or unsigned scripts. |
 | For - creates a loop consisting of three optional expressions
enclosed in brackets and separated by semicolons, and a block of
statements to be executed. |
 | For...In - used to iterate a declared variable over every
property in a specified object. |
 | Function - declares a function with its specified parameters,
which can include numbers, strings and objects. To return a value, a
function must have a return statement specifying the value to
return. |
 | If...Else - executes one set of statements if a specified
condition is true, and another if it is false. |
 | Import - allows a script to import properties, functions and
objects exported by a signed script. |
 | Label - used to identify a statement allowing you to refer to it
elsewhere in a program, typically used with the break or continue
statements. |
 | Return - specifies the value to be returned by a function and
performs the act of returning that value to where the function was called
from. |
 | Switch - tests an expression against a number of case
options and executes the statements associated with the first one to
match. |
 | throw - allows the programmer to create an exception. This exception
can be a string, integer, Boolean or an object. |
 | try...catch - used to test a block of code for errors. The try
block contains the code to be run, while the catch block contains
the code to execute if there is an error. |
 | Var - used to declare a variable, and outside of a function its
use is optional. |
 | While - creates a loop consisting of a block of statements that
is executed if the expression evaluated is true. |
 | With - establishes a default object for a set of statements. If
there are any unqualified names in a set of statements, JavaScript first
checks the default object to see if they exist there as properties of that
object; otherwise a local or global variable is used.
|
Note: this page is adapted from devguru.com, javascript.com, and Microsoft
resources.
|