JavaScript
Browser side scripting language.
typeof
Section titled “typeof”typeof can be used to find the datatype of a particular variable. e.g. if you run:
var i = "12";var iType = typeof i;var j = 12;var jType = typeof j;alert("iType: " + iType);alert("jType: " + jType);You will get the following 2 alerts:
iType: stringjType: numberYahoo UI (YUI)
Section titled “Yahoo UI (YUI)”We’ve used the YUI toolkit to help with some design and coding of front end user interfaces. Its very neat and relatively easy to setup. Visit the official YUI library for more information.
Objects and their properties
Section titled “Objects and their properties”Below is an example of initializing objects and modifying their properties.
// create empty objectvar exampleObject = {};// create apple with some propertiesvar apple = { colour: "green", price: 1.25, variety: "granny smith"};// change the apple's colour to red using square brackets and quotes.apple["colour"] = "red";// change it back to green using dot notation.apple.colour = "green";// add a new propertyapple.weightInGrams = 300;// delete the new propertydelete apple.weightInGrams;// enumerate through all properties of the applefor (name in apple) { document.write(name + ": " + apple[name]);}The above will output
colour: greenprice: 1.25variety: granny smithStrings
Section titled “Strings”String substitution with Regular Expressions
Section titled “String substitution with Regular Expressions”Use the String replace method. Regular expressions are part of standard JavaScript.
"a/long/dir/filename.mp3".replace(/^.*\//, "")will return
"filename.mp3"