Unary operators are operators with only one operand. Unary operators are more efficient than standard JavaScript function calls. Additionally, unary operators can not be overridden and therefore their functionality is guaranteed.
The following unary operators are available:
Operator | Operation | Example |
---|---|---|
delete | The delete operator deletes a property from an object. | example |
void | The void operator discards an expression's return value. | example |
typeof | The typeof operator determines the type of a given object. | example |
+ | The unary plus operator converts its operand to Number type. | example |
- | The unary negation operator converts its operand to Number, then negates it. | example |
~ | Bitwise NOT operator. | example |
! | Logical NOT operator. | example |