Think JavaScript is only good for image swaps and flying <div>s?Think again - this article takes an in-depth look at some of theobject-oriented constructs available in JavaScript, and demonstrates howJavaScript objects can substantially speed up code development anddeployment.
The object Sumthing now has two properties, "alpha" and
"beta". With this, it is possible to create an instance of the object Sumthing, and pass it two parameters ("num1" and "num2"), which are then stored as object properties ("alpha" and "beta"). Note my use of the "this" keyword, which provides a convenient way to access variables (and functions) which are "local" to the object constructor.
Let's take it for a spin.
<script language="JavaScript">
obj = new Sumthing(2, 89);
alert("alpha is " + obj.alpha);
alert("beta is " + obj.beta);
</script>