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 |
different between web server and application server
What is javascript tree shaking?
what is interface ?
What are the methods of validating whether the form is secure?
Is javascript object a hash table?
What is the purpose of using javascript?
What are decodeuri() and encodeuri() functions in javascript?
What does js stand for?
Can I learn javascript without html?
What are the different actions that are performed using javascript?
What is the prototype object in javascript and how it is used?
What is whitespace in javascript?