You can prepare effectively for Software Development JavaScript for Web Development with this dedicated MCQ Practice Test (available with solutions) on the important topic of "Test: Functions - 1". These 15 questions have been designed by the experts with the latest curriculum of Software Development 2026, to help you master the concept.
Test Highlights:
Sign up on EduRev for free to attempt this test and track your preparation progress.
Which of the following statements is true about JavaScript functions?
Detailed Solution: Question 1
What is the purpose of using parameters in JavaScript functions?
Detailed Solution: Question 2
Which of the following options correctly represents the syntax to define a function in JavaScript?
Detailed Solution: Question 3
Detailed Solution: Question 4
What is the difference between function declarations and function expressions in JavaScript?
Detailed Solution: Question 5
What will be the output of the following JavaScript code?
function greet() {
console.log("Hello, World!");
}
greet();
Detailed Solution: Question 6
What will be the output of the following JavaScript code?
function sum(a, b) {
return a + b;
}
var result = sum(3, 4);
console.log(result);
Detailed Solution: Question 7
What will be the output of the following JavaScript code?
var multiply = function(a, b) {
return a * b;
};
console.log(multiply(2, 5));
Detailed Solution: Question 8
What will be the output of the following JavaScript code?
var x = 5;
function updateX() {
var x = 10;
}
updateX();
console.log(x);
Detailed Solution: Question 9
What will be the output of the following JavaScript code?
var x = 5;
function updateX() {
x = 10;
}
updateX();
console.log(x);
Detailed Solution: Question 10
Consider the following JavaScript code:
var calculate = function(a, b, operation) {
return operation(a, b);
};
function add(a, b) {
return a + b;
}
var result = calculate(3, 4, add);
console.log(result);
What will be the output of the above code?
Detailed Solution: Question 11
Consider the following JavaScript code:
function outer() {
var x = 10;
function inner() {
console.log(x);
}
return inner;
}
var closureFn = outer();
closureFn();
What will be the output of the above code?
Detailed Solution: Question 12
Consider the following JavaScript code:
function multiplyBy(factor) {
return function(number) {
return number * factor;
};
}
var multiplyByTwo = multiplyBy(2);
var multiplyByFive = multiplyBy(5);
console.log(multiplyByTwo(3));
console.log(multiplyByFive(4));
What will be the output of the above code?
Detailed Solution: Question 13
Consider the following JavaScript code:
function outer() {
var x = 10;
function inner() {
console.log(x);
var x = 20;
}
inner();
}
outer();
What will be the output of the above code?
Detailed Solution: Question 14
Consider the following JavaScript code:
var x = 5;
function updateX() {
x = 10;
}
setTimeout(updateX, 1000);
console.log(x);
What will be the output of the above code?
Detailed Solution: Question 15
51 videos|32 docs|12 tests |