What does +_ operator mean in JavaScript ?

Unary Operator: A unary operation contain only one operand. Here, the ‘+’ unary plus operator converts its operand to Number type. While it also acts as an arithmetic operator with two operands which returns an addition result on calculation.
- JavaScript Identifiers: Javascript Identifiers are used to name variables (and keywords, functions, and labels). In Javascript, the first character must be a letter, or an underscore ( _ ), or a dollar sign ( $ ) but not a digit and subsequent characters may be letters, digits, underscores, or dollar signs.
- JavaScript +_ operator: It is a combination of the variable with the symbol underscore( _ ) and unary plus ( + ) operator, + operator converts the type of _ variable to Number type for further operation.
Example: The variable “_” with string type is stored in variable “r” with “number” type.
Input:
var _ = "1"; var r = +_;
Output:
typeof(r) will be number
Example 1: Conversion of String to Number
HTML
| <bodystyle="text-align:center">     <divclass="container">         <h1style="color:green">Geeks for Geeks</h1>          <h3>             Javascript Operator         </h3>          <palign="center">             Type of variable(_) :             <spanid="gfg"></span> <br/>             Type of variable(a) :             <spanid="gfg1"></span>         </p>          <scripttype="text/javascript">             GFG = function (_) {                 let b = typeof _;                 let a = +_;                 let c = typeof a;                              document.getElementById("gfg").innerHTML = b;                 document.getElementById("gfg1").innerHTML = c;             };                          GFG("21");         </script>     </div> </body> | 
Output:
 
+_ operator in JavaScript
Example 2: Performing arithmetic addition operations by converting them to number type.
HTML
| <bodystyle="text-align:center">     <divclass="container">         <h1style="color:green">             zambiatek         </h1>          <h3>             Addition Operation         </h3>          <palign="center">             Value variable(_) :             <spanid="gfg"></span> <br/>             Value of variable($) :             <spanid="gfg1"></span> <br/>             Value of variable(Sum) :             <spanid="gfg2"></span>         </p>          <scripttype="text/javascript">             GFG = function (_, $) {                 let c = +_ + +$;                 let a = +_;                 let b = +$;                              document.getElementById("gfg").innerHTML = a;                 document.getElementById("gfg1").innerHTML = b;                 document.getElementById("gfg2").innerHTML = c;             };                          GFG("21", "45");         </script>     </div> </body> | 
Output:
 
+_ operator in JavaScript
 
				 
					


