Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...

How do you create a new object in JavaScript?

Answer Posted / sri

The following function can be used as demonstrated to create
an object of class myobject:

function myobject() {
this.containedValue = 0;
this.othercontainedValue = 0;
this.anothercontainedValue = 0;
}

var mything = new myobject();
And there you go, mything is now an instance of class
myobject. It will have the following properties, all of
which will be 0:

* mything.containedValue
* mything.othercontainedValue
* mything.anothercontainedValue

You could also now write
myobject.prototype.newContainedValue = someValue; and all
instances of class myobject will have the property
newContainedValue with value someValue.

Is This Answer Correct ?    7 Yes 4 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

How much do javascript programmers make?

914


What is the difference between var and let?

949


Is javascript the future?

963


What is difference between local variable and global?

939


How do I start a javascript project?

990


What are arrays in javascript?

965


How will you get the checkbox status whether it is checked or not?

885


What does “1?+2+4 Evaluate to? What about 5 + 4 + “3??

1006


What is are the types of the pop up box es available in javascript?

974


What is Unobtrusive JavaScript & Why it's Important?

1076


In which location cookies are stored on the hard disk?

984


Should you use var or let?

1003


Explain event bubbling and event capturing in javascript?

935


What would be the result of 2+5+”3″?

926


What is string in javascript?

1070