Call object member function : Member Function : Object Oriented JAVASCRIPT TUTORIALS


JAVASCRIPT TUTORIALS » Object Oriented » Member Function »

 

Call object member function

















<html>
<head>
<title>Example</title>
</head>
<body>
<script type="text/javascript">
function createCar(color, doors, mpg) {
    var tempcar = new Object;
    tempcar.color = color;
    tempcar.doors = doors;
    tempcar.mpg = mpg;
    tempcar.showColor = function () {
        alert(this.color)
    };

    return tempcar;
}

var car1 = createCar("red"423);
var car2 = createCar("blue"325);
car1.showColor();
car2.showColor();


</script>

</body>
</html>







HTML code for linking to this page:

Follow Navioo On Twitter

JAVASCRIPT TUTORIALS

 Navioo Object Oriented
» Member Function