Skip to content
- What does JS stand for?
- A) Java System
- B) JavaScript
- C) Jumping Script
- D) None of the above
- Which of the following is a JavaScript data type?
- A) Number
- B) String
- C) Boolean
- D) All of the above
- Where is client-side JavaScript executed?
- A) Server
- B) Client’s browser
- C) Cloud
- D) Mainframe
- Which of the following is the correct syntax to declare a variable in JavaScript?
- A) var variableName;
- B) variable variableName;
- C) v variableName;
- D) declare variableName;
- What symbol is used for comments in JavaScript?
- How do you create a function in JavaScript?
- A) function = myFunction()
- B) function myFunction()
- C) function:myFunction()
- D) myFunction = function()
- Which of the following is not a reserved keyword in JavaScript?
- A) function
- B) let
- C) var
- D) objectify
- How to write an if statement in JavaScript?
- A) if i = 5 then
- B) if (i == 5)
- C) if i == 5
- D) if i = 5
- What is the output of the following code:
console.log(typeof(null));?
- A) “null”
- B) “object”
- C) “undefined”
- D) “number”
- Which method is used to round a number in JavaScript?
- A) Math.ceil()
- B) Math.round()
- C) Math.floor()
- D) Math.random()
- What will be the result of
"5" + 3 in JavaScript?
- A) 8
- B) “53”
- C) 53
- D) “8”
- How do you add a comment in JavaScript?
- A) /* comment */
- B) // comment
- C) # comment
- D) Both A and B
- Which of the following methods can be used to add an element to the end of an array?
- A) push()
- B) add()
- C) append()
- D) insert()
- What does NaN stand for in JavaScript?
- A) Not a Number
- B) Negative a Number
- C) Null a Number
- D) None of the above
- What keyword is used to define a constant in JavaScript?
- A) constant
- B) const
- C) finalize
- D) let
- Which operator is used to assign a value to a variable in JavaScript?
- How can you convert a string to a number in JavaScript?
- A) parseInt()
- B) Number()
- C) Both A and B
- D) ToString()
- Which of the following is the correct way to write an array in JavaScript?
- A) var arr = (1, 2, 3)
- B) var arr = [1, 2, 3]
- C) var arr = {1, 2, 3}
- D) var arr = <1, 2, 3>
- How do you define an object in JavaScript?
- A) var obj = {}
- B) var obj = []
- C) var obj = ()
- D) var obj = <>
- What is the output of
console.log(2 + '2');?
- A) 4
- B) 22
- C) “4”
- D) “22”
- What will be the output of
typeof([]);?
- A) “array”
- B) “object”
- C) “list”
- D) “undefined”
- In JavaScript, which symbol is used for logical AND?
- What is the output of
console.log(1 == '1');?
- A) true
- B) false
- C) undefined
- D) NaN
- Which method is used to remove the last element from an array?
- A) pop()
- B) shift()
- C) slice()
- D) delete()
- What is the purpose of the
this keyword in JavaScript?
- A) Refers to the current function
- B) Refers to the current object
- C) Refers to the parent object
- D) None of the above
- What does the
Array.isArray() method do?
- A) Checks if the value is an array
- B) Creates a new array
- C) Converts an array to a string
- D) None of the above
- Which of the following is not a looping structure in JavaScript?
- A) for
- B) while
- C) do-while
- D) until
- How do you access the first element of an array named
myArray?
- A) myArray[0]
- B) myArray(1)
- C) myArray{1}
- D) myArray.first()
- What keyword is used to create a new object in JavaScript?
- A) new
- B) create
- C) class
- D) object
- Which built-in method combines two or more arrays?
- A) combine()
- B) concat()
- C) merge()
- D) join()
- Which of the following functions can be used to display data in an alert box?
- A) window.alert()
- B) alert()
- C) Both A and B
- D) Show.alert()
- What is the purpose of the
return statement in a function?
- A) To end the function
- B) To return a value
- C) Both A and B
- D) To pause the function
- How do you check for an undefined variable in JavaScript?
- A) if(variable === null)
- B) if(variable === undefined)
- C) if(variable == undefined)
- D) All of the above
- Which of the following will cause an error in JavaScript?
- A) var a = 1;
- B) var a = “Hello”;
- C) var a = undefined;
- D) var a = NaN;
- How do you create a new empty object in JavaScript?
- A) var obj = {};
- B) var obj = [];
- C) var obj = new Object();
- D) Both A and C
- How do you define a named function in JavaScript?
- A) function myFunction() { }
- B) function = myFunction() { }
- C) myFunction() { }
- D) function:myFunction() { }
- What will
console.log(0.1 + 0.2 === 0.3); output in JavaScript?
- A) true
- B) false
- C) undefined
- D) NaN
- Which of the following is not a valid variable name in JavaScript?
- A) myVar
- B) $myVar
- C) my-var
- D) _myVar
- How do you define an arrow function in JavaScript?
- A) const myFunction = () => { }
- B) const myFunction = function() { }
- C) myFunction() => { }
- D) function => myFunction() { }
- In JavaScript, which symbol is used for logical OR?
- How can you create an instance of an object in JavaScript?
- A) Using the
new keyword
- B) Simply declaring it
- C) Using the
create method
- D) None of the above
- What is the output of
console.log(1 < 2 < 3);?
- A) true
- B) false
- C) NaN
- D) undefined
- Which of the following is a way to iterate over an array?
- A) forEach()
- B) map()
- C) filter()
- D) All of the above
- Which function is used to parse a string to an integer in JavaScript?
- A) parseFloat()
- B) toNumber()
- C) parseInt()
- D) convert()
- How do you prevent a default action in an event handler?
- A) event.preventDefault()
- B) return false
- C) Both A and B
- D) stopPropagation()
- What is a closure in JavaScript?
- A) A scope that contains variables
- B) A defined function inside another function
- C) Both A and B
- D) A way to close an application
- What will
null == undefined return in JavaScript?
- A) true
- B) false
- C) undefined
- D) NaN
- In which situation would you use the
JSON.parse() method?
- A) To convert an object to a string
- B) To convert a string to an object
- C) To parse JSON data from an API
- D) Both B and C
- Which of the following can throw an error in JavaScript?
- A) Syntax error
- B) Reference error
- C) Type error
- D) All of the above
- What does the
map() method return?
- A) A new array with the results of calling a function for every array element
- B) A single value
- C) The original array
- D) An object