Home > Client Side Scripting > Object di Javascript

Object di Javascript

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.đŸ™‚

  1. No comments yet.
  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: