Archive

Archive for October, 2014

Object di Javascript

October 30, 2014 Leave a comment

Object dalam javascript dapat dibentuk dengan 3 cara yaitu :

1. Object Literal

var objectName = {

propertyName_1 : value_1,

propertyName_2 : value_2,

propertyName_3 : value_3,

propertyName_n : value_n

};

2. Object Constructor

function ConstructorName ( value_1, value_2, value_3, value_n){

propertyName_1 : value_1,

propertyName_2 : value_2,

propertyName_3 : value_3,

propertyName_n : value_n

}

var objectName = new ConstructorName( value_1, value_2, value_3, value_n);

3. Javascript keyword new

var objectName = new Object();

objectName.propertyName_1 = value_1;

objectName.propertyName_2 = value_2;

objectName.propertyName_3 = value_3;

objectName.propertyName_n = value_n;

Semoga bermanfaat. 🙂