Sign value of added plus in javascript

What is the β€œ+" effect in the following?

var result = jQuery.trim(this.html2val(this.getValueJelement()[0].innerHTML));
    result = +result.replace(/[^\d\.-]/g, '');
+5
source share
3 answers

This is essentially a hidden way of forcing the right operand to a numerical value. For instance.

> +"42"
42
+11
source

It converts the operand to a number. In other words, this is basically the same as saying result = parseFloat(result).

+2
source

+ais the fastest way to convert ato number.

+1
source

All Articles