Reflection and Prototyping in JS

Prototyping in java script is nothing but act as an Java Interface. Meaning it’s used to define the methods of the object.

 

 

Reflection in java script is used to observe the content of the object. As for modification we can use method expansion:

ex.:

<p style=”line-height: 18px; font-size: 18px; font-family: times;”>
Click “<i>Load samples</i>” to view and edit more JS samples.<br>

function display(p) {

if (p.hasOwnProperty(‘name’)) {
p.name.lastname = ‘Terry’;
alert(p.name.firstname);
}
}

var person = { combinedname: { fistname: ‘John’ }};
display(person);

</p>

Advertisements

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