NEW
Font size
WorksheetsBasic JavaScript
Total questions: 15
Worksheet time: 8mins
What is the correct way to declare a variable in JavaScript?
variable = 10;
const variable = 10;
variable := 10;
variable == 10;
What is the result of the following expression: 5 + "5";
10
"55"
Nan
Error
Which function is used to display a message in the browser's console
console.print()
log()
print()
console.log()
What is the correct way to create a function in JavaScript?
function = myFunction() {}
function myFunction() {}
let myFunction() {}
function myFunction: {}
What is the output of the following code?
10
5
undefined
Error
What is the correct way to create an array in JavaScript?
array = [1, 2, 3];
array(1, 2, 3);
array = {1, 2, 3};
array = (1, 2, 3)
What is the result of the expression true && false
true
false
undefined
Error
What is the correct way to create an object in JavaScript?
object = {name: "John", age: 30}
object(name = "John", age = 30)
object = (name: "John", age: 30)
object = [name: "John", age: 30]
What does the === operator in JavaScript do?
Checks for equality of values and data type
Checks for equality of values and not data types
Assigns a value to a variable
Performs a bitwise OR operation
What is the correct way to access the length of an array in JavaScript?
array.length()
length(array)
array.length
array.getLength()
What is the correct way to access the value of a property in an object?
object.propertyName
object.getProperty("propertyName")
object.getPropertyName()
object(propertyName)
What is the correct way to remove the last element from an array in JavaScript?
array.removeLast()
array.popLast()
array.pop()
array.deleteLast()
var result = 10 + "20" - 5;result = "5025"
result = "205"
result = 1015
Error
Which method is used to convert a string to uppercase in JavaScript?
toUpperCase
toUpper
upperCase
convertToUpper
What is the output of the code?
Error
10
20
undefined
