Can someone please explain the below code for me?
Any help is greatly appreciated.
var balance = $(".input-balance"), value = $(".balance-value"), reevVal, mmaVal = $(".mma-val span"), mmareev, amaVal = $(".ama-val span"), amareev, triggerPlus = "false", triggerMinus ="false", fvVal;
var x = 0, y, z = 1
is equivalent to
var x = 0;
var y; // undefined
var z = 1
There's also the similar, but different, comma operator that lets you "group" up multiple expressions into a single expression. The value of the last sub-expression is returned, but all sub-expressions are evaluated:
let x = (5, doSix(), 7); // x = 7
x = 8, doNine(), 10; // 10
Note the parens are necessary in the 1st line above to make it clear it's a single declaration and not a list of declarations like in the 1st example. The parens aren't necessary in the 2nd line, since there's not let|var|const so it's not a declaration, but an assignment.
In practice, it's most common in for loops where you're constrained to a single expression:
for (let i = 0, j = 10; i < j; i++, j--)
console.log(i, j);