Javascript Tutorial Appendices
The tutorial appendices are a synopsis of important objects, methods, properties, functions and reserved words. The terms used will help you access an appropriate reference that explains in detail what the term means.
Reserved Words
Reserved words are words that can't be used as identifiers. Many of them are keywords that have a special purpose in JavaScript.
abstract boolean break byte case catch char class const continue debugger default delete do double else enum export extends false final finally float for function goto if implements import in instanceof int interface long native new null package private protected public return short static super switch synchronized this throw throws transient true try typeof undefined var void volatile while with
To avoid unnecessary debugging problems NEVER use any property or method name as a variable name. Also avoid using a case variant even when it is legal (eg. do not use instanceOf).
Built-In Functions
JavaScript includes several useful built-in functions. For example:
| escape() | Many special characters cause problems when submitting information to a CGI server. These characters include $ # ! spaces and tabs. Example: coded=escape('& '); [returns "%26%20"]. |
| eval() | Evaluates a string and executes it as if it was script code. This can be very dangerous! |
| isFinite() | Tests whether the variable is a finite number. Returns false if contents is not a number or is infinite. Example: flag = isFinite(var_name); |
| isNaN() | Tests whether the variable is not a number. Returns true if contents is not a decimal based number. Example: flag = isNaNum(var_name); |
| Number() | Converts the object's argument to a number representing the object's
value. If the value cannot be represented by a legitimate number,
the "Not-a-Number" value, NaN is returned. Note the inconsistency in case!! |
| parseFloat() | Turns a string into a floating-point number. If the first character can't be converted the result is NaN. Otherwise the conversion stops at first character that can't be converted. The function is decimal base only! Example: n = parseFloat('23.45'); |
| parseInt() | Turns a string into an integer number. If the first character can't be converted the result is NaN. Otherwise the conversion stops at first character that can't be converted. If a second parameter is included, the numeric base can be binary, octal, decimal or hexadecimal. Example: n = parseInt('55',10); which places the number 55 into the base 10 variable n. |
| unescape() | Recovers an escaped string. Example:
decoded=unescape('%26%20'); [returns "& "]. |
| new | Creates a copy or instance of an object for use or modification within a program. For example now = new Date; creates a Date object called now that can be affected by all the Date properties and methods. Technically new is an operator but it works very much like a function! |
| this | A shorthand convention to allow working with the current object method without naming it. This is used to save retyping a method name. |
| with | A shorthand convention to allow working with the current object
without naming it. This is used to save retyping a long object name.
Example: is:with (document) {
writeln(lastmodified);
writeln(location);
writeln(title);
} |
ECMA Core Objects, Methods & Properties
ECMA objects are specific core objects (or internal constructs) defined by the ECMA standards committee. Some objects are used to access operating system functions. Others are used to perform data and string manipulations. The ECMA objects are Array, Boolean, Date, Error, Function, Global, Image, Math, Number, Object, RegExp and String.
- Array Object
- properties - constructor, length, prototype
- methods - concat(), join(), pop(), push(), reverse(), shift(), slice(), sort(), splice(), toLocaleString(), toString(), unshift(), valueOf()
- Boolean Object
- properties - constructor, prototype
- methods - toString(), valueOf()
- Date Object
- properties - constructor, prototype
- methods - getDate(), getDay(), getFullYear(), getHours(), getMilliseconds(), getMinutes(), getMonth(), getSeconds(), getTime(), getTimeZoneOffset(), getUTCDate(), getUTCDay(), getUTCFullYear(), getUTCHours(), getUTCMilliseconds(), getUTCMinutes(), getUTCMonth(), getUTCSeconds(), getVarDate(), getYear(), parse(), setDate(), setFullYear(), setHours(), setMilliseconds(), setMinutes(), setMonth(), setSeconds(), setTime(), setUTCDate(), setUTCFullYear(), setUTCHours(), setUTCMilliseconds(), setUTCMinutes(), setUTCMonth(), setUTCSeconds(), setUTCTime(), setUTCYear(), setYear(), toLocaleString(), toUTCString(), toString(), UTC(), valueOf()
- Error Object
- properties - description, number
- methods -
- Function Object
- properties - arguments[], caller, constructor, prototype
- methods - toString(), valueOf()
- Global Object
- properties - Infinity, NaN, undefined
- methods - escape(), eval(), isFinite(), isNaN(), parseFloat(), parseInt(), unescape()
- Image Object
- properties - border, complete, height, hspace, lowsrc, name, prototype, src, vspace, width
- methods -
- Math Object
- properties - E, LN10, LN2, LOG10E, LOG2E, PI, SQRT2, SQRT1_2
- methods - abs(), acos(), asin(), atan(), atan2(), ceil(), cos(), exp(), floor(), log(), max(), min(), pow(), random(), round(), sin(), sqrt(), tan()
- Number Object
- properties - MAX_VALUE, MIN_VALUE, NaN, NEGATIVE _INFINITY, POSITIVE_INFINITY, constructor, prototype
- methods - toLocaleString(), toString(), valueOf()
- Object Object
- properties - constructor, prototype
- methods - toLocaleString(), toString(), unwatch(), valueOf(), watch()
- RegExp Object
- properties - $1 - $9, ignoreCase, index, input, lastIndex, lastMatch, lastParen, leftContext, rightContext
- methods - compile(), exec(), test()
- String Object
- properties - constructor, length, prototype
- display methods - anchor(), big(), blink(), bold(), fixed(), fontcolor(), fontsize(), italics(), small(), strike(), sub(), sup()
- manipulation methods - charAt(), charCodeAt(), concat(), fromCharCode(), indexOf(), lastIndexOf(), link(), match(), replace(), search(), slice(), split(), substr(), substring(), toLowerCase(), toUpperCase(), toString(), valueOf()
DOM Objects, Methods & Properties
DOM objects are defined by w3.org standards committee.
- Event Object -
- properties - altKey, button, clientX, clientY, ctrlKey, keyCode, metaKey, relatedTarget, screenX, screenY, shiftKey
Client Objects, Methods & Properties
Client objects are objects tied to a particular browser. This may cause some inconsistencies in syntax or use in different browsers or as versions change. Be aware that differences do exist and always test your documents. The client objects are Document, Form, History, Location, Navigator and Window.
- Document Object - Primary Output
- content properties - anchors[], applets[], embeds[], forms[], images[], links [], plugins[]
- display properties - alinkColor, bgColor, fgColor, linkColor, vlinkColor
- information properties - cookie, domain, lastModified, mimeTypes, referrer, title, URL
- methods - open(), write(), writeln()
- Form Objects - Primary Input
- form properties - name, target, action, method, encoding, elements, length
- form methods - submit(), reset()
- button, hidden, reset, and submit object properties - name, value, type
- checkbox properties - name, value, type, checked, default checked
- password properties - name, value, type, default value
- radio button properties - name, value, type, checked, default checked, length
- select properties - name, value, type, length, options, defaultSelected, index, selected, selectedIndex
- text, textarea properties - name, value, defaultvalue
- input, textarea and select methods - focus(), blur(), select()
- History Object - Access the browser's history file
- properties - length
- methods - back(), forward(), go()
- Location Object
- properties - hash, host, hostname, href, pathname, port, protocol, search
- methods - assign(), reload(), replace(), toString()
- Navigator Object - Root of all Objects
- properties - appCodeName, appName, appVersion, platform, userAgent
- methods - javaEnabled()
- Window Object
- properties - defaultStatus, frames, length, name, opener, parent, self, status, top, window
- methods - alert(), blur(), clearInterval(), clearTimeout(), close(), confirm(), focus(), open(), print(), prompt(), scrollTo(), setInterval(), setTimeout(), timeoutID()
- contained objects -
- Screen Object
- properties - availHeight, availLeft, availTop, availWidth, colorDepth, height, pixelDepth, width