What is the + operator before a variable in Javascript?
It converts a String variable to a Number, if possible: +'21.2'
equals Number(21.2)
. If the conversion fails, it return NaN
(that's where || 0
kicks in in your example code)
It is a way to make a variable value to number, if the variable has a number. alternative you can use Number
function.