0
0
Javascriptprogramming~5 mins

Unary operators in Javascript - Cheat Sheet & Quick Revision

Choose your learning style9 modes available
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?
A||
B&&
C==
D+
What is the result of +"5" in JavaScript?
A5 (number)
B"5" (string)
CNaN
Dundefined
What does typeof null return?
A"null"
B"boolean"
C"object"
D"undefined"
What does the delete operator do?
ADeletes a property from an object
BDeletes a variable
CDeletes a function
DDeletes an array element by index
What is the result of -true in JavaScript?
ANaN
B-1
C1
Dfalse
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.