- AString
- BArray
- CBoolean
- DNumber
Time Taken:
Correct Answer:
Wrong Answer:
Percentage: %
In JavaScript, the primitive data types are String, Boolean, Number, Null, and Undefined.
An array is not a primitive data type, but is instead an object.
The && operator in JavaScript performs a logical AND operation on its operands.
If both operands are truthy, the result is true, otherwise the result is false.
In this case, the first operand (x) is truthy (true), but the second operand (y) is falsy (false), so the result of the && operation is false.
The ++ operator in JavaScript is an increment operator, which increments a number by 1.
In this case, the variable num is initially assigned the value 10, which is a number.
On the second line, num is incremented by 1 using the ++ operator.
Therefore, num now has a value of 11, and when it is logged to the console, the value 11 will be displayed.
In JavaScript, the + operator can be used to add numbers or concatenate strings.
If both operands are numbers, the + operator will perform addition.
If either operand is a string, the + operator will treat both operands as strings and perform string concatenation.
In this case, the first operand (num1) is a number, but the second operand (num2) is a string.
Therefore, the + operator will treat both operands as strings and perform string concatenation, resulting in the string "1020".
The Map data type in JavaScript is a constructor that creates a new map object, which is a collection of key-value pairs.
The set method is used to add a new key-value pair to the map object.
In this case, two key-value pairs are added to the map object using the set method.
The size property is used to get the number of key-value pairs in the map object.
Since there are 2 key-value pairs in the map object, the size property will return 2.
The Set data type in JavaScript is a constructor that creates a new set object, which is a collection of unique values.
The add method is used to add a new value to the set object.
The has method is used to determine whether the set object includes the specified value.
In this case, two values are added to the set object using the add method.
The has method is called on the set object, with the value 2 as the argument.
Since the set object includes the value 2, the has method will return true.
The Object.is method in JavaScript is a method that can be used to determine whether two values are the same.
In this case, the Object.is method is called with obj and an empty object as the arguments.
Although obj and the empty object may seem similar, they are actually two distinct objects and are not the same.
Therefore, the Object.is method will return false.
The Array.isArray method in JavaScript is a method that can be used to determine whether a value is an array.
In this case, the Array.isArray method is called with the array [1, 2, 3] as the argument.
Since the value is an array, the Array.isArray method will return true.
This function takes in a single argument, name, and returns a greeting string that includes the name.
This function takes in a single argument, radius, and uses the Math.PI constant and the radius to calculate the area of a circle.