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 |
Is html and javascript the same?
Which built-in method returns the length of the string?
What is javascript and how it works?
How do you implement Ajax using hide() function in JQuery?
Which built-in method returns the characters in a string beginning at the specified location?
Define escape() function?
What is the main difference between Client side JavaScript and and Server side Java Script?
Why javascript is called lightweight language?
Example of using regular expressions for syntax checking in javascript?
Where do you write javascript?
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
Event handler Example