typeof Operator
The JavaScript typeof operator returns the data type of its operand in the form of a string. The operand can be any object, function, or variable.
Syntax:
typeof operand
Example: In this example, The typeof operator is used to check the data types of variables. Outputs: “number”, “string”, “boolean”, “object”, and “undefined” for each respective variable.
Javascript
let num = 18; let str = "w3wiki" ; let isTrue = true ; let obj = { name: "Aman" , age: 21 }; let undefinedVar; console.log( typeof num); console.log( typeof str); console.log( typeof isTrue); console.log( typeof obj); console.log( typeof undefinedVar); |
number string boolean object undefined
JavaScript Unary Operators
JavaScript Unary Operators work on a single operand and perform various operations, like incrementing/decrementing, evaluating data type, negation of a value, etc.
Table of Content
- Unary Plus (+) Operator
- Unary Minus (-) Operator
- Unary Increment (++) Operator
- Unary Decrement (–) Operator
- Logical NOT (!) Operator
- Bitwise NOT (~) Operator
- typeof Operator
- delete Operator
- void Operator
We will explore all the above operators along with their basic implementation with the help of examples.