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 do you clear an array in javascript?
In Java coding we will write a public static void main()? Why won't we write as a static public void main()
What is dataview in javascript?
How to determine the state of a checkbox using javascript?
Are there any iphone Institutes which also train iphone automation testing in Hyderabad?
Write the code to maximize an image using javaScript?
Is there automatic type conversion in JavaScript?
Explain how can you submit a form using JavaScript?
List some of the advantages of javascript.
What is difference between local and global scope in javascript ?
What exactly does javascript do?
Which is best for front end?