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

TypeError: document.getelementbyid(...) is null?

1000


Some XYZ company is arranging for online aptitude tests. Draw detailed E-R diagram for the same..

2167


What is the use of document object?

964


What is difference between promise and callback?

1070


How to count the number of element in an array using javascript?

1213


Can you assign an anonymous function to a variable and pass it as an argument to another function?

919


What is strict mode in javascript?

1120


What are types of javascript?

973


What do mean by NULL in Javascript?

1165


What is the difference between remove() and removeChild()?

1127


Is javascript frontend or backend?

932


What is an onclick?

967


What does parse Query String return in javascript?

1002


can wwe trace a java program (class)

2401


What is undefined x 1 in JavaScript?

1037