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 |
How to create an object using javascript?
Which company developed JavaScript?
Which parameter of load ()' s callback function has the data?
How to create a popup warning box?
Is javascript case sensitive language?
What does the isNaN() function?
Is javascript a dynamic language?
How to achieve inheritance in javascript?
Is jquery easier than javascript?
Which is best for front end?
Name the different types of pop up boxes in Javascript?
How can we detect os of the client machine using javascript?