Recall & Review
beginner
What is a unary operator in JavaScript?
A unary operator is an operator that works with only one operand. It performs an operation on a single value or variable.
Click to reveal answer
beginner
What does the unary plus (+) operator do?
The unary plus (+) operator converts its operand to a number if it is not already one.
Click to reveal answer
beginner
How does the unary negation (-) operator work?
The unary negation (-) operator converts its operand to a number and then negates it, changing its sign.
Click to reveal answer
beginner
What is the purpose of the typeof operator?
The typeof operator returns a string indicating the type of the operand, such as 'number', 'string', or 'object'.
Click to reveal answer
intermediate
What does the delete operator do in JavaScript?
The delete operator removes a property from an object. It returns true if the property was successfully deleted or did not exist.
Click to reveal answer
Which of the following is a unary operator in JavaScript?
✗ Incorrect
The plus (+) operator used alone is unary, working on one operand. The others are binary operators.
What is the result of +"5" in JavaScript?
✗ Incorrect
The unary plus converts the string "5" to the number 5.
What does typeof null return?
✗ Incorrect
typeof null returns "object" due to a historical JavaScript quirk.
What does the delete operator do?
✗ Incorrect
The delete operator removes a property from an object, not variables or functions.
What is the result of -true in JavaScript?
✗ Incorrect
true converts to 1, then unary negation changes it to -1.
Explain what unary operators are and give three examples in JavaScript.
Think about operators that work with only one value.
You got /2 concepts.
Describe how the delete operator works and when you might use it.
It is not used to delete variables.
You got /3 concepts.