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 |
Do hackers use javascript?
How is a relation not a function?
Explain the working of timers in JavaScript? Also elucidate the drawbacks of using the timer, if any?
In which location cookies are stored on the hard disk?
Javascript, Pass by Value or Pass by Reference?
What does parse Query String return in javascript?
How are object properties assigned?
can any one tell me the syllebus for java certification
List the comparison operators supported by javascript?
How to reload a page using JavaScript?
Explain unescape() and escape() in javascript?
What is the use of a map object in javascript?