Other Types of Operators

  • JavaScript has a few additional operators that can be convinient, and are worth mentioning. You likely would not use these as frequently as the other operators already discussed.

1. Type Of : The type of operator returns the data type of a specified variable, object, function, etc.

  • Operator: typeof
  • Examples:

    let car = "Honda";
    typeof car; //this line returns "string" because the value of car is a string
    let x, y;
    let equation = x + 5 / (6 * y) + 17;
    typeof equation; //this line returns "number" because the value returned from evaluating the equation is a number
    
Other Types of Operators JavaScript has a few additional operators that can be convinient, and are worth mentioning. You likely would not use these as frequently as the other operators already discussed. 1. Type Of : The type of operator returns the data type of a specified variable, object, function, etc. Operator: typeof Examples: let car = "Honda"; typeof car; //this line returns "string" because the value of car is a string let x, y; let equation = x + 5 / (6 * y) + 17; typeof equation; //this line returns "number" because the value returned from evaluating the equation is a number