
Q61
Q61 Consider this code:
new Promise((resolve, reject) => {
throw new Error('Error');
})
.catch(error => console.log(error.message))
.then(() => console.log('Completed'));
What will be the output?
'Error' then 'Completed'
Just 'Error'
Just 'Completed'
A runtime error
Q62
Q62 Which of the following is a correct syntax to display “Hello World” in an alert box using JavaScript?
alertBox('Hello World');
alert('Hello World');
msgAlert('Hello World');
displayAlert('Hello World');
Q63
Q63 Which of the following is an example of a loosely typed language?
Java
C++
JavaScript
Python
Q64
Q64 Which operator is used to check both the value and the type of a variable in JavaScript?
==
===
!=
!==
Q65
Q65 What is the output of the following code snippet?
let x = 'Hello';
let y = 'World';
console.log(x + ' ' + y);
HelloWorld
'Hello World'
'Hello' 'World'
Hello World
Q66
Q66 What is the output of this code snippet?
for (let i = 0; i < 3; i++) {
console.log(i);
}
012
123
0-1-2
1-2-3
Q67
Q67 Consider the following code:
let x = 5;
let result = (x > 3) ? 'Yes' : 'No';
console.log(result);
What is the output?
'Yes'
'No'
true
false
Q68
Q68 Find the error in the following code:
for (let i = 0; i <= 5; i++) {
if(i % 2 == 0) continue;
console.log(i);
}
It doesn't print any number
It only prints odd numbers
It only prints even numbers
Syntax error
Q69
Q69 What is the purpose of a function in JavaScript?
To store data
To repeat a task multiple times
To encapsulate code that performs a specific task
To create web pages
Q70
Q70 How do you define a function in JavaScript?
function = myFunc() {}
function: myFunc() {}
function myFunc() {}
myFunc() = function {}
Q71
Q71 What will be the output of this function call?
function sum(a, b) {
return a + b;
}
console.log(sum(3, 4));
3
4
7
Error
Q72
Q72 In JavaScript, what is a callback function?
A function that runs after the page loads
A function passed as an argument to another function
A function that calls itself
A function that performs an HTTP request
Q73
Q73 Which of the following is true about arrow functions in JavaScript?
They do not have their own this context
They can be used as constructors
They must have a return statement
They are the same as traditional functions
Q74
Q74 Consider the following code snippet:
function greet() {
return 'Hello World';
}
console.log(greet());
What is the output?
'greet'
'Hello World'
undefined
Error
Q75
Q75 Identify the error in this function:
function multiply(a, b) {
console.log(a * b);
}
It does not return any value
It returns the wrong value
Syntax error
No error
Q76
Q76 What is wrong with this function declaration?
function power(base, exponent) {
if (exponent == 0) return 1;
else return base * power(base, exponent - 1);
} console.log(power(2));
It doesn't handle the case when exponent is not provided
It returns the wrong value
It causes an infinite loop
Syntax error
Q77
Q77 Which method is used to add an element to the end of an array in JavaScript?
push()
unshift()
pop()
shift()
Q78
Q78 How do you find the length of an array in JavaScript?
array.size()
array.length
array.count()
length(array)
Q79
Q79 What does the splice method do in an array?
Copies a portion of an array
Concatenates arrays
Changes the content of an array
Finds an element in an array
Q80
Q80 Which of the following array methods in JavaScript does not change the original array?
sort()
splice()
forEach()
push()
Q81
Q81
[1, 2, 3, 4]
[10, 20, 30, 40]
[0.1, 0.2, 0.3, 0.4]
Error
Q82
Q82 What will be the output of this code snippet?
let numbers = [1, 2, 3];
numbers[10] = 11;
console.log(numbers.length);
3
4
11
10
Q83
Q83 Identify the issue in this array declaration:
let numbers = new Array(-5);
Negative size
Syntax error
Logical error
No error
Q84
Q84 How do you access the value of a property in a JavaScript object?
object{propertyName}
object[propertyName]
object.propertyName
Both B and C
Q85
Q85 Find the issue in this object definition:
let obj = { '1a': 10, b: 20 };
console.log(obj.1a);
Invalid property name
Syntax error in console.log
Incorrect value assignment
No error
Q86
Q86 Identify the error in this object method:
let obj = {
greet: function() {
return 'Hello, ' + name;
}
};
console.log(obj.greet());
name is not defined
greet is not a function
Syntax error
No error
Q87
Q87 Which JavaScript method is used to select an HTML element by its ID?
getElementById()
querySelector()
getElementsByClassName()
getElementsByTagName()
Q88
Q88 What is the difference between innerHTML and textContent properties in DOM manipulation?
innerHTML can include HTML tags; textContent cannot
textContent is faster than innerHTML
textContent can include HTML tags; innerHTML cannot
There is no difference
Q89
Q89 Consider this code:
let items = document.querySelectorAll('.item');
console.log(items.length);
What does it output if there are three elements with class item in the HTML?
3
'item'
undefined
Error
Q90
Q90 Spot the mistake in this code:
let btn = document.getElementById('submit');
btn.onClick = function() {
console.log('Clicked');
};
Incorrect event handler
Missing element with id 'submit'
Syntax error in the function
No error

