This is the second day of my participation in the November Gwen Challenge. Check out the details: the last Gwen Challenge 2021

We all know the addition, subtraction, multiplication and division (+/-/*//) operators, but there are others. We all know how to use typeof, what its function is, what is its name? That’s right! You guessed it, it’s also an operator

Operators in JavaScript

Common JavaScript operators can be divided into two categories:

  • Prefix operator
  • Infix operator

Of course, there is also a class of operators called bitwise operators. This article will explore common bitwise operators and then learn to break them.

1. Prefix operators

There are three prefix operators

1. +: Converts to a numeric type

+, when used as a prefix operator, is used to convert the target to a numeric type, returning NaN non-numeric if the conversion fails. Therefore, it is recommended to use the Number function directly because the semantics of Number are clearer. This NaN non-number is a bit fuzzy and a bit buggy in JavaScript. Keep reading for NaN:

2. -: reverse positive and negative,

– When used as a prefix operator, it changes the value of the target

3. typeof

The Typeof is also an operator that returns a type: say typeof(621). If the target of typeof judgment is a numeric type, the prefix operator will return number, and even NaN,

So what is this NaN? It is non-numeric, and the NaN attribute is a special value that represents a non-numeric value. This property is used to indicate that a value is not a number. You can set the Number object to this value to indicate that it is not a numeric value. Use the isNaN() global function to determine if a value is a NaN

NaN means non-number, but typeof(NaN) returns number for determining the typeof number

A small forecast

This article looked at three prefix operators in JavaScript, and I’ll continue with the infix operator..