0% found this document useful (0 votes)
12K views2 pages

Assignment 1 - Javascript PDF

The document contains 8 questions about JavaScript concepts like loops, functions, operators, arrays and more. Question 1 asks about the output and reasons for loops with setTimeout. Question 2 asks about function output based on variable scope and declaration. Question 3 asks to write a program to display the current day and time. Question 4 is a multiple choice question about Array methods. Question 5 asks about valid JavaScript operators. Question 6 asks about variable scope in functions. Questions 7 and 8 are multiple choice questions about operator precedence and short-circuit evaluation.

Uploaded by

Niraj Singh
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
12K views2 pages

Assignment 1 - Javascript PDF

The document contains 8 questions about JavaScript concepts like loops, functions, operators, arrays and more. Question 1 asks about the output and reasons for loops with setTimeout. Question 2 asks about function output based on variable scope and declaration. Question 3 asks to write a program to display the current day and time. Question 4 is a multiple choice question about Array methods. Question 5 asks about valid JavaScript operators. Question 6 asks about variable scope in functions. Questions 7 and 8 are multiple choice questions about operator precedence and short-circuit evaluation.

Uploaded by

Niraj Singh
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

ASSIGNMENT 1 - JAVASCRIPT

Ques 1) Find the output of the followings (along with the reasons):-

a) for(var i = 0; i<10; i++){


console.log("i >>>>" , i);
setTimeout(function(){
console.log(i);
},1000)
}

b) for(let j = 0; j<10;ji++){
console.log("j >>>>" , j);
setTimeout(function(){
console.log(j);
},1000)
}

Ques 2) Find the output of the followings:-

a) function abc(){
console.log(b)
}
let b = 'delta';
abc();

b) function abc(){
console.log(c)
}
abc();
let c = 'delta';

Ques 3) Write a JavaScript program to display the current day and time in the following format.
Sample Output :​ Today is : Tuesday.
Current time is : 10 PM : 30 : 38

Ques 4) The _____ method of an Array object adds and/or removes elements from an array.
A. Reverse
B. Shift
C. Slice
D. Splice

Ques 5) Which of the following is not considered a JavaScript operator?


A. new
B. this
C. delete
D. typeof

Ques 6) Write the output for the following code, also define reason

var a=10

let func = ()=>{


console.log(a)
for(var a=1; a<5; a++)
{
console.log(a)
}
console.log(a)
}

func()

Q7) - Which of the following is the output of the below JavaScript code?

​var​ x ​=​ ​[​typeof​ x​,​ ​typeof​ y​][​1​];

​typeof​ ​typeof​ x​;

1. "undefined"
2. "number"
3. "string"
4. "object"

Ques 8) Select the output for the following code , also explain it

let​ a = (​"success"​ && ​"not success"​) || ​1


console.log(a);

1. Success
2. not success
3. 1
4. undefined

You might also like