How do you create a new object in JavaScript?
Answers were Sorted based on User's Feedback
Answer / 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 |
What does the enableviewstatemac setting in an aspx page do?
What causes memory leaks?
What is a function callback?
How do I activate javascript on my phone?
What are the advantages of javascript?
how can we retrieve value from one database server and store them another database server using sql server code
Is there any class in javascript?
What are the problems associated with using javascript, and are there javascript techniques that you discourage?
How to import all exports of a file as an object.
Are there any training Institutions on iphone Automation testing?
What are events in javascript?
Why is javascript so hard?