Syntax for checking a numeric field for a value
I've used both of these approaches successfully but would like to know which is the preferred way to add numeric field values?
a. Is example 2 preferred to example 1, or 1 preferred to 2?
b. When adding a series of numbers as in these examples, is it always preferable to enclose the number variables in parenthesis?
c. In example 1, is using "this.getField" preferred over "getField"
d. Is there a better way to do this?
e. Does either of these approaches encourage concatenating values vs. totaling their values, so that 1 + 2 + 3 + 4 = 1234 instead of = 10?
Example 1
var m01 = getField("num.CD.M.01");
var m02 = getField("num.CD.M.02");
var m03 = getField("num.CD.M.03");
var m04 = getField("num.CD.M.04");
var creditsTotal = this.getField("num.CreditsTotal");
creditsTotal.value = m01.value + m02.value + m03.value + m04.value;
Example 2
var m01 = +getField("num.CD.M.01").value;
var m02 = +getField("num.CD.M.02").value;
var m03 = +getField("num.CD.M.03").value;
var m04 = +getField("num.CD.M.04").value;
var creditsTotal = this.getField("num.Credits");
creditsTotal.value = (m01 + m02 + m03 + m04);
