Javascript

Browser side scripting language.

1. 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: string
jType: number

2. Yahoo UI (yui)

We've recently begun using the yui toolkit to help with some design and coding of front end user interfaces. Its very neat and relatively easy to setup. You can visit the official YUI library site for more information.

3. Objects and their properties

Below is an example of initializing objects and modifying their properties.

// create empty object
var exampleObject = {};
// create apple with some properties
var 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 property
apple.weightInGrams = 300;
// delete the new property
delete apple.weightInGrams;
// enumerate through all properties of the apple
for (name in apple) {
  document.write(name + ": " + apple[name]);
}

The above will output

colour: green
price: 1.25
variety: granny smith