A customer hands over a balance of 0, an empty name or null: the || lane and the ?? lane each decide when the fallback is used, and a counting ambil() shows…
Every "give it a default" is a choice between || and ??. Pick wrong and a quantity of 0, an empty string or a false toggle is swallowed by the fallback with no error. It is one of the most common modern JavaScript traps.
|| asks "falsy?", ?? asks "null or undefined?"
0 or an empty string is quietly swapped for the fallback For numbers and strings, 0 and '' are valid values that || swallows. Use ?? for defaults.?? with || or && a ?? b || c is rejected before it runs. Add explicit brackets: (a ?? b) || c.0 passes a "filled in?" check with ?? ?? only checks null and undefined. '' and 0 count as present. For "not empty", check it yourself: teks.trim() !== ''.'' or false to ?? ?? lets it through: '' and false count as present.null or undefined Only here do both rules agree to take the fallback.ambilCadangan() as the fallback Count its calls: || calls it for 0, ?? does not. The right side runs only when needed.