Changes

Jump to: navigation, search

JavaScript Object Basics

620 bytes added, 20:32, 25 April 2007
Creating and using Object Instances
Lets now bring all of this together in a complete example within an HTML page:
<pre>
<html>
<head>
<title>A Simple JavaScript Function Example</title>
<script language="JavaScript" type="text/javascript">
 
function car (make, model, color)
{
this.make = make;
this.model = model;
this.color = color
this.displayCar = displayCar;
}
function displayCar()
{
document.writeln("Make = " + this.make)
}
</script>
 
</head>
 
<script language="JavaScript" type="text/javascript">
myCar = new car ("Ford", "Focus", "Red");
myCar.displayCar();
myCar.make = "BMW";
myCar.displayCar();
</script>
 
</body>
</html>
</pre>
== Creating and using Object Instances ==

Navigation menu