interpreted by a web browser, but it doesn't have to; it has in fact been used for years by sysadmins alongside VBScript to manage local Windows networks of PCs.
Modern websites relying so heavily on this scripting language, companies added " JIT" compilation to their browser (most notably Google Chrome's V8 engine). Once downloaded from the web server, the code is compiled into machine code (executes much faster). Here's the full listing of tutorials: read through it for a great overview, or refresh your
memory. For in-depth info, just click on the corresponding link! The web browser
window object and document object (" DOM") include methods and functions to manipulate the content of the page and interact with its display, timing, etc.
clearInterval() stops recurring timers stored in variables and started with setInterval(), by name.
clearTimeout() cancels a timer created with setTimeout(), using its variable name.
getElementById() takes an id attribute as argument, and returns the matching element, if any.
getElementsByTagName() takes an HTML tag name as argument, and returns all matching nodes.
setInterval() creates a recurring timer (in loop), that triggers code at regular millisecond intervals.
setTimeout() creates a countdown timer that will run code or a function once the interval elapses.
Redirect visitors to another page with a simple line of code, optionally after a delay.
Convert hours, minutes, and seconds to milliseconds and get equivalency table, useful for timers. The
String object, designed to hold text, is the most common data type since most scripts handle strings: HTML tags, web page content, or form fields values filled-in by users.
Declare a string in four different ways: constructor, literal, toString(), or as returned result.
The length property counts the number of characters, and can be used as position index.
charAt() takes a position index as argument, and returns the character if found there in a string.
charCodeAt() returns the unicode value of the character it found at the position index supplied.
concat() joins together pieces of text passed as argument, and adds them to another string.
fromCharCode() returns the string corresponding to the unicode value(s) passed as argument.
indexOf() is the quickest way to check if a string contains another one (case-sensitive search).
lastIndexOf() returns the character position index of the last instance of a string found in another.
match() returns an array of matches to a regular expression pattern applied on a string.
replace() substitutes all RegEx matches it finds with a another string passed as argument.
search() looks for a regular expression in strings, and returns first match's character position index.
slice() extracts a substring from a string, with optional negative index (to start from the end!)
split() uses the string you pass as argument to separate text into an array of strings.
substring() lets you extract custom-length strings from inside another piece of text.
toLowerCase() returns an all-minuscules copy of a string (" abc").
toUpperCase() returns a fully capitalized copy of a string (" ABC").
Count the number of a times a string appears in another with literal string or regular expressions.
Remove leading and trailing spaces from strings using two very simple regular expressions.
Get the current URL and split it into usable pieces - protocol, domain, page, arguments...
Reverse words in a sentence: account for multiple spaces, forced line breaks and other oddities. The
object, initially the least intuitive topic to understand, is a most powerful and flexible technique you'll end up using it all the time for text manipulation and form validation. RegExp The
The Array length property counts the number of elements; it is zero when the array is empty.
Array concat() * appends elements or arrays (in the case of multidimensional) to an existing array.
join() returns all array elements as a string, optionally separated with a delimiter.
pop() removes the last element of an array, and returns its value - original array shorter by 1.
push() adds one or more elements at the end of an array, and returns the new length.
reverse() returns a copy of an array in inverse order (the first element becomes the last one).
shift() removes and returns an array's first element - original array then shorter in length by 1.
Array slice() * extracts one array from another, and also is useful to create a full copy (clone).
sort() is applied on an array, and returns a copy of that array sorted in alphabetical order.
splice() lets you most flexibly insert, delete, and interpolate / replace elements in an array.
unshift() adds a new element at the beginning of an array, and returns the updated array's length.
* Note: these methods have the same name as String methods, but are applied on arrays.
Sort array elements by length (the number of characters they each contain), from shortest to longest.
Create associative arrays - use custom string keys instead of a numbered index to access elements. The
Number object stores numeric values, both integers and floating points. Numbers evaluate also as boolean (zero and negative numbers as false, positive numbers as true).
Declare a number variable using the contructor, assigning a numeric value, or capturing values.
isNaN() only returns true when the argument passed is numeric (" NaN" stands for " Not a Number").
parseFloat() gets floating point values out of non-number types, or converts integers to floats.
parseInt() extracts an integer (whole number) from a string + workaround around its limitation.
toFixed() returns the string representation of a number with X decimal places, rounding if needed.
Add zeros in front of numbers or after the decimal with a custom function that returns a string. The
unary negation operator (exclamation mark) returns the opposite of the expression that follows, if it were evaluated as a boolean value. Tip: two exclamation points convert to boolean!