An Object Lesson In JavaScript (
Page 1 of 9 )
Think JavaScript is only good for image swaps and flying <div>s?
Think again - this article takes an in-depth look at some of the
object-oriented constructs available in JavaScript, and demonstrates how
JavaScript objects can substantially speed up code development and
deployment.It's sad but true - there are a whole bunch of people out there who think that
JavaScript is only good for image swaps and ticker tapes.
I'm here to
tell you that it ain't so.
Yes, JavaScript is a client-side scripting
language; most often, it's used to make objects fly around on a Web page, or
validate the data entered into an HTML form. But, once you go beyond the obvious
and dig a little deeper, it will become obvious that there's a whole lot more to
this simple, easy-to-learn language.
In order to illustrate this, I'm
going to spend the next few pages exploring some of the object-oriented
constructs available in JavaScript. You didn't know you could use
object-oriented concepts in JavaScript?! Shock, shock! Horror,
horror!
Now, JavaScript doesn't offer nearly as much power and
flexibility in its object model as do languages like Java and Perl; however, as
you will see, even the limited features available can come in quite handy at
times. And, with a little bit of thought, a clever developer like you can use
JavaScript objects to substantially reduce the time spent on code development
and testing...while simultaneously gaining the respect of your colleagues and
the admiration of the pretty girl next door.
Let's get on with it, shall
we?