...
Question 1719 – Image-Processing
November 27, 2023
Question 7641 – Data-Interpretation
November 27, 2023
Question 1719 – Image-Processing
November 27, 2023
Question 7641 – Data-Interpretation
November 27, 2023

Question 5118 – UGC NET CS 2018 JUNE Paper-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 :

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”
A
M=3; D1 displays ”12”; D2 displays ”6”; D3 displays ”12”.
B
M=3; D1 displays ”6”; D2 displays ”12”; D3 displays ”6”.
C
M=2; D1 displays ”6”; D2 displays ”12”.
D
M=2; D1 displays ”12”; D2 displays ”6”.
0 0 votes
Article Rating
Subscribe
Notify of
0 Comments
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x
error: Alert: Content selection is disabled!!