Which of the following statements is true about JavaScript functions?
What is the purpose of using parameters in JavaScript functions?
Which of the following options correctly represents the syntax to define a function in JavaScript?
What is the difference between function declarations and function expressions in JavaScript?
What will be the output of the following JavaScript code?
function greet() {
console.log("Hello, World!");
}
greet();
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);
What will be the output of the following JavaScript code?
var multiply = function(a, b) {
return a * b;
};
console.log(multiply(2, 5));
What will be the output of the following JavaScript code?
var x = 5;
function updateX() {
var x = 10;
}
updateX();
console.log(x);
What will be the output of the following JavaScript code?
var x = 5;
function updateX() {
x = 10;
}
updateX();
console.log(x);
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?
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?
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?
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?
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?
51 videos|30 docs|12 tests
|