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 can the os of the client machine be detected?
What are parameters in javascript?
What is enum with example?
what is service now ticketing tool how it works
When selecting the states by giving the country as input using ajax cal, how can we ensure that every time it is hitting the DB and fetching the data? Many time it may load from the cache.
What are javascript properties?
What is escape & unescape String functions in JavaScript?
how can we create own web browser?
How do you include a comment in javascript?
How do you convert numbers between different bases in JavaScript?
4 Answers College School Exams Tests, Satyam, UIST, Wipro,
What are the uses of javascript in web page designing?
How to make a function in javascript?