Last Modified: 03/29/07 - (under construction)
| Item | Description |
| Organizations | Organizations
|
| <script> Tag: JavaScript vs JScript vs VBScript |
JavaScript vs JScript
Example of a simple JavaScript function. <head> |
| Browser Environment Info | Browser Environment Info
|
| Variables: Visibility | Visibility
|
| Variables: Naming Conventions | Variable Naming Conventions This is my suggestion. I follow this same type of "Variable Naming Convention" for other languages.
|
| functions | functions
|
| Function | Description |
| Script Tags | |
| Comments | Comments
|
| var | var <variable name> Returns: Nothing Declares a variable. Examples: var blnDebug = true, strDebugMsg = "", <more statements ...>; var strHml = ""; Var info - see the section called: "Variables: Visibility" |
| Control Structure: if() |
Control Structure: if()
|
| Control Structure: Looping |
Control Structure:
Looping Control Structure: Examples
Control Structure: Looping - for
Control Structure: Looping - miscellaneous statements
|
| with | |
| function & return | |
| new | |
| this | |
| Item | Information |
| Create an Object & List it's properties | Example:
JavaScript Objects - Create & List Properties
function fObjectCreateAndList() { |
| Global Objects - you can't loop through the values. | With Global Object, to my knowledge you
can't loop through the properties. Ex: Math, Date |
| Item | Description |
| setTimeout() | |
| typeof | Determine the type of Variable or if
it doesn't exists ("undefined"). Note: This is vary handy when you needed it !!! Examples
|
| void("") or void(0) | Not sure what this does, but here is
how I use it. Example #1: void('') - (note: 2 single quotes - not 1 double quote). This example allows me to run a JavaScript function and not change the web screen. <script language="JavaScript"> function fMyFunction(strMsg) { alert(strMsg) } </script> <a href="javascript:fMyFunction("Hello World");void('')">Development Testing</a> |
| eval() | Evaluates an expression. This is
a way to dynamically create JavaScript and then run it. You
can dynamically create a name of an object in a text string and the
eval() the string to return the value. |
| escape() | escape(<string> [,1]) Returns: String (encoded) Returns an "escaped string" (URL encoded). (Note: spaces are converted to %20 etc....). Used to encode a string for the URL line. Example: Optional parm value of 1 = Encode the "+" sign also. |
| isNaN() | Evaluates and argument to determine if
it's "Not a Number" |
| Number() | |
| parseFloat() | Converts a string to a float. Warning: parseInt('09') = 0 |
| parseInt() | Converts a string to an integer. var intTest = parseInt( <string> ); |
| String() | |
| unescape() | unescape(<encoded
string>) Returns: String Returns a string value of an "escaped string". (Note: %20 converted to space, etc....) Example: var strUnEncoded = unescape("Hello%20World") Returns: "Hello World" see: escape() |
| unwatch() | Used with some browsers for debugging code. |
| watch() | Used with some browsers for debugging code. |
| Item | Description |
| General Info | Creating a String: strExample = "Hello World" strExample = 'Hello World' strExample = new String("Hello World") Joining Strings: |
| Relevant functions: split() parseInt() |
split() - see "Array Functions"
section. parseInt() - see General & Global functions. |
| <string>.indexOf() | intReturn = <string object>.indexOf(<string
to find>,intStartingPosition) 0 = 1st Char Examples: |
| String() | String( <object or value> ) Returns: String Returns a string representation of the parm. Same as <object>.toString() Example: String( <array object> ) - returns a comma-delimited string of the contents. |
| <string>.replace() |
Replace a char with a char. strSource = "Hello"; Example:
replace() |
| <string>.substring |
Returns a substring of a string based
on a Start & Stop index value. <string>.substring(StartIndex, StopIndex) |
| <string>.substr |
Returns a substring of a string based
on a Start index value and then a length of characters. <string>.substr(start [, length ]) |
| <string>.toLowerCase() |
Returns the lower case value of the
string.
|
| <string>.toUpperCase() | Returns the upper case value of the
string. ex: "Hello World".toUpperCase() |
| Item | Description |
| Relevant functions described in other sections | Global Functions (see the other
section)
|
| Examples |
|
| abs | Math.abs( var ) - Absolute value.
(Returns the positive number.) Ex: Math.abs( 1 ) = 1 Math.abs( -1 ) = 1 Math.abs( -100.123 ) = 100.123 |
| acos | Math.acos( var ) - Arc cosine (in radians). |
| asin | Math.asin( var ) - Arc sine (in radians). |
| atan | Math.atan( var ) - Arc tangent (in radians). |
| atan2 | Math.atan2( var1, var2) - Angle of polar coordinates x and y |
| ceil | Math.ceil( var ) - round up to the
next integer. Ex: Math.ceil(1.1) = 2 Math.ceil(1.5) = 2 Math.ceil(1.9) = 2 |
| cos | Math.cos( var ) - Cosine |
| exp | Math.exp( var ) - Power of |
| floor | Math.floor( var ) - round down to the
previous integer. Ex: Math.floor(1.1) = 1 Math.floor(1.5) = 1 Math.floor(1.9) = 1 |
| log | Math.log( var ) - Natural logarithm. |
| max | Math.max( var1, var2) - Returns the
greater value of the arguments. Ex: Math.max( 1.1, 1.5) = 1.5 |
| min | Math.min( var1, var2) - Returns the
lesser value of the arguments. Ex: Math.min( 1.1, 1.5) = 1.1 |
| pow | Math.pow(var1, var2) - Returns var1 to
the power of var2. Ex: Math.pow(10,2) = 100 |
| random | Math.random() - Returns a Random
number between 0 and 1. Ex: Math.random() = 0.18925420584172098 Math.random() = 0.5879989492922739 Math.random() = 0.03670801222553011 Example of generating a random
number between 1 and 6 (rolling dice) |
| round | Math.round( var ) - Returns the
rounded integer. ( >= .5 will be the next integer). Ex: Math.round(1.1) = 1 Math.round(1.5) = 2 Math.round(1.9) = 2 |
| sin | Math.sin( var ) - Sin (in radians) |
| sqrt | Math.sqrt( var ) - Square root Ex: Math.sqrt(9) = 3 |
| tan | Math.tan( var ) - Tangent (in radians) |
| Item | Description |
| General Information | General Information
|
| Relevant functions described in other sections | |
| Examples |
|
| Create a Date object |
var dateToday = new Date(); var dateHired = new Date("11/01/2007");
|
| Year | Year - <YYYY>
|
| Month of year | Month - 0-11 (0=Jan thru 11=Dec)
|
| Date in month | Date - 1-31 Date within the month.
|
| Day of week |
Day - 0-6 day of week (Sunday=0)
|
| Hour of day (24hr) |
Hours - 0-23 Hour of the day in 24
hour format.
|
| Minute of hour | Minutes - 0-59 Minute
|
| Second of minute | Seconds - 0-59 Second
|
| Time in Milliseconds | Time - Milliseconds since 1/1/1970
00:00:00 GMT.
|
| getTimezoneOffset() | |
| toGMTString() | |
| toLocaleString() | |
| toString () | |
| Date.UTC( dateValue ) | |
| Date.parse(strDate) |
| Item | Description |
| Relevant functions described in other sections | |
| Array | Array
var arrTemp = ["Item 1", "Item 2", "Item 3"];
var arrDateDaysFull = ["Sunday", "Monday", "Tuesday",
"Wednesday", "Thursday", "Friday", "Saturday"]; |
| Array Properties | Array Propterties
|
| concat() | |
| join() | |
| push() | |
| pop() | |
| reverse() | |
| shift() | |
| slice() | |
| sort() | |
| unshift() | |
| split() | Converts a string to an array. <Array> = String.split(<string for the separator value>) Returns: Array Ex 1: Return an array of the cookie values: (the separator value is "; ") var arrCookieInfo = document.cookie.split("; "); |
| Need to check on: arrMy.contains(<string value>) |
| Number Object | The Number Object is normally not
needed because the native number in JavaScript can accomplish almost
all of your needs. var objMyNumber = new Number( 10 ); Number.MAX_VALUE |
| Boolean Object | The Boolen Object is normally not
needed because the native number in JavaScript can accomplish almost
all of your needs. var objMyBoolean = new boolean(true); Boolean.toString() Also has a prototype property. |
| Function | Description |
| <object>.toString() | <object>.toString() Returns a string value representing the value of the object. ex: <array object>.toString() - returns a comma-delimited string of the contents. |
| Window | Window Object
|
| abstract boolean break byte case catch char class const continue default delete do double |
else 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 var void while with |
| Item | Description |
| Under Construction |
action alert alinkColor anchor method Anchor object anchors appCodeName Applet applets appName appVersion Area arguments array arguments property Array back bgColor big blink blur bold Boolean border Button caller charAt Checkbox checked clearTimeout click close (document object) close (window object) closed complete confirm constructor cookie current Date defaultChecked defaultSelected defaultStatus defaultValue description document domain E elements array elements property embeds array enabledPlugin encoding escape eval fgColor filename FileUpload fixed focus fontcolor fontsize Form object form property forms forward Frame frames Function go hash height Hidden history array history object host hostname href hspace Image images index italics javaEnabled lastIndexOf lastModified length link method Link object linkColor links LN2 LN10 location LOG2E LOG10E lowsrc Math MAX_VALUE method MimeType mimeTypes MIN_VALUE name NaN navigator NEGATIVE_INFINITY next Number onAbort onBlur onChange onClick onError onFocus onLoad onMouseOut onMouseOver onReset onSelect onSubmit onUnload open (document object) open (window object) opener Option options parent parse parseFloat Password pathname PI Plugin plugins port POSITIVE_INFINITY previous prompt protocol prototype Radio referrer refresh reload replace reset method Reset object scroll search select method Select object selected selectedIndex self small split SQRT1_2 SQRT2 src status strike String sub submit method Submit object suffixes sup taint taintEnabled target Text object text property Textarea title top type |