Question 1719 – Image-Processing
November 27, 2023Data-Interpretation
November 27, 2023UGC NET CS 2018 JUNE Paper-2
Question 2 |
Consider the JavaScript Code :
var y= ’’12”;
function f( )
{
var y=’’6”;
alert (this.y);
function g( )
{
alert (y);
}
g( );
}
f( );
If M is the number of alert dialog boxes generated by this JavaScript code and D1, D2, …., DM represents the content displayed in each of the M dialog boxes, then :
var y= ’’12”;
function f( )
{
var y=’’6”;
alert (this.y);
function g( )
{
alert (y);
}
g( );
}
f( );
If M is the number of alert dialog boxes generated by this JavaScript code and D1, D2, …., DM represents the content displayed in each of the M dialog boxes, then :
M=3; D1 displays ”12”; D2 displays ”6”; D3 displays ”12”. | |
M=3; D1 displays ”6”; D2 displays ”12”; D3 displays ”6”. | |
M=2; D1 displays ”6”; D2 displays ”12”. | |
M=2; D1 displays ”12”; D2 displays ”6”. |
Question 2 Explanation:
The JavaScript this keyword refers to the object it belongs to.
It has different values depending on where it is used:
In a method, this refers to the owner object.
Alone, this refers to the global object.
In a function, this refers to the global object.
In an event, this refers to the element that received the event.
Methods like call(), and apply() can refer this to any object.
There are two alert boxes in the javascript code.So two messages will be displayed.
First message, alert(this.y) here this.y is global variable whose value is 12 So first message is “12”.
Second message is alert(y) , here “y” local variable and value is 6 so second message displays value “6”
It has different values depending on where it is used:
In a method, this refers to the owner object.
Alone, this refers to the global object.
In a function, this refers to the global object.
In an event, this refers to the element that received the event.
Methods like call(), and apply() can refer this to any object.
There are two alert boxes in the javascript code.So two messages will be displayed.
First message, alert(this.y) here this.y is global variable whose value is 12 So first message is “12”.
Second message is alert(y) , here “y” local variable and value is 6 so second message displays value “6”
Correct Answer: D
Question 2 Explanation:
The JavaScript this keyword refers to the object it belongs to.
It has different values depending on where it is used:
In a method, this refers to the owner object.
Alone, this refers to the global object.
In a function, this refers to the global object.
In an event, this refers to the element that received the event.
Methods like call(), and apply() can refer this to any object.
There are two alert boxes in the javascript code.So two messages will be displayed.
First message, alert(this.y) here this.y is global variable whose value is 12 So first message is “12”.
Second message is alert(y) , here “y” local variable and value is 6 so second message displays value “6”
It has different values depending on where it is used:
In a method, this refers to the owner object.
Alone, this refers to the global object.
In a function, this refers to the global object.
In an event, this refers to the element that received the event.
Methods like call(), and apply() can refer this to any object.
There are two alert boxes in the javascript code.So two messages will be displayed.
First message, alert(this.y) here this.y is global variable whose value is 12 So first message is “12”.
Second message is alert(y) , here “y” local variable and value is 6 so second message displays value “6”
Subscribe
Login
0 Comments