this keyword in javascript

This page neatly explains about “this” keyword

From javascript object oriented programming concepts –

The this keyword inside a constructor function refers to the object that’s being created.

Quoting below example from

function myFunc(StringValue){  <br>
this.StringValue = StringValue;  <br>
}  <br>
var myObject = new myFunc("This is myObject's string");  <br>
var myObject2 = new myFunc("This is a String");  <br>
alert(myObject.StringValue); // displays "This is myObject's string"  <br>
alert(myObject2.StringValue); // displays "This is a String"


Leave a Reply

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

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

Google+ photo

You are commenting using your Google+ 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 )


Connecting to %s

%d bloggers like this: