-
In a function, which statement is used to return a value?
- return
- break
- continue
- var
-
About function, which statement is NOT correct
- Function always returns value
- Function is a value or object
- Function has no block scope
- Function name is optional
-
The variable defined in the function is
- Local variable
- Global variable
- Parameter
- Outer variable
-
About the var keyword, which statement is correct?
- 'var' is a keyword
- 'var' variables has no block scope
- 'var' variables tolerates redeclaration
- 'var' variables can be declared below their use
-
What is the difference between var and let
- var is global, let is local
- var is block scope, let is function scope
- var is hoisted, let is not
- var is redeclarable, let is not
-
What is the difference between function and arrow function?
- Function is a value, arrow function is a function
- Function is a class, arrow function is a function
- Function is a class, arrow function is a value
- Function is a value, arrow function is a class
-
Result of the code: "let sum = new Function('a', 'b', 'return a + b');alert(sum(1, 2));" is
- 3
- NaN
- 1
- undefined
-
Which of the following is the result of the code when user input 10:
let age = prompt("What is your age?", 18);
let welcome = (age < 18) ?
() => alert('Hello') :
() => alert("Greetings!");
welcome();
- Hello
- Greetings!
- undefined
- NaN
-
What is the result of the code:
function sum(a, b) {
return a + b;
}
alert(sum(1, 2) + sum(4, 5));
- 12
- NaN
- 9
- 3
-
What is the result of the code:
let userName = 'John';
function showMessage() {
let userName = "Bob";
alert(userName);
}
showMessage();
alert(userName);
- Bob John
- Bob Bob
- John John
- Error
-
What is the result of the code if the use entered '3':
let num = prompt("Please enter a number");
alert(`${num + 3}`);
- 3
- 6
- 3+3
- 33