How do you create a new object in JavaScript?
Answer Posted / 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 |
Post New Answer View All Answers
Write a Program using Servlet and JDBC for developing online application for displaying the details of Cars owned by the residents in XYZ society. Make necessary assumptions and create appropriate databases
What is an object in javascript, give an example?
What is this? Var myarray = [[[]]];
Does html5 replace javascript?
When would you use javascript closures?
What is escape() function?
How does javascript work?
Name the different types of pop up boxes in Javascript?
How to get the primitive value of a string in Javascript?
What javascript means?
What is scope javascript?
What are the ways to define a variable in javascript?
What are the new ways to define a variable in Javascript?
How are DOM utilized in JavaScript?
What is console.log() and why it is used?