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 |
Which built-in method reverses the order of the elements of an array?
How will you create new object in javascript?
Is it possible to do 301 redirects in javascript ?
What is argument objects in javascript?
What is this keyword?
9 Answers Cognizant, Infosys, Satyam,
What is difference between module.exports and export?
What is event bubbling in the dom?
Event handler Example
what data type javascript supports?
What does trim stand for?
Can you explain the difference between == and ===?
Name the numeric constants representing max, min values?