JavaScript Multiple choices


Total available count: 50
Subject - JavaScript Frameworks
Subsubject - JavaScript

In JavaScript, How generic objects can be created?


 

 

 

 



B


Solution:-

Any function in JavaScript can be used to create custom object classes, simply by calling it using the keyword new. When called in this way, the special variable inside the function references the new object that is being constructed (it normally refers to the 'current' object, which is usually the window, except inside methods). The function should not return a value. 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

 




Next 5 multiple choice(s)

1

In JavaScript,The methods push(), pop(), shift(), unshift() works on?

2

var data = [ "X" ];data.push( "S" );data.push( "D", "E" );What is result of data?

3

var data = [ "X" ];data.unshift( "S" );data.unshift( "D", "E" ); What is result of data?

4

var data = [ "X", "Y", "Z" ];data.pop(); What is the output of this code?

5

var data = [ "X", "Y", "Z" ];data.shift(); What is the output of this code?

Comments