JavaScript Objects Introduction
JavaScript is an Object Oriented Programming (OOP) language.
An OOP language allows you to define your own objects and mae your own variable
types.
Object Oriented Programming
JavaScript is an Object Oriented Programming (OOP) language. An OOP language allows you to
define your own objects and mae your own variable types.
!owever" creating your own objects will be e#plained later" in t$e Advanced JavaScript section. %e
will start by looing at t$e built&in JavaScript objects" and $ow t$ey are used. '$e ne#t pages will
e#plain eac$ built&in JavaScript object in detail.
(ote t$at an object is just a special ind of data. An object $as properties and met$ods.
Properties
Properties are t$e values associated wit$ an object.
In t$e following e#ample we are using t$e lengt$ property of t$e String object to return t$e number
of c$aracters in a string)
<script type="text/javascript">
var txt="Hello World!";
document.write(txt.lent!";
</script>
'$e output of t$e code above will be)
#$
*et$ods
*et$ods are t$e actions t$at can be performed on objects.
In t$e following e#ample we are using t$e to+pper,ase() met$od of t$e String object to display a
te#t in uppercase letters)
<script type="text/javascript">
var str="Hello world!";
document.write(str.to%pper&ase("";
</script>
'$e output of t$e code above will be)
H'(() W)*(+!