JavaScript: Passing Values by Reference or by Value
In JavaScript, the way values are passed depends on whether they are primitive types or objects. Primitive types, which include numbers, strings, booleans, null, undefined, and symbols, are passed by value. When a primitive value is passed to a function, a copy of that value is made, and any modifications made to the copy will not affect the original value. For example: const increment = num => { num = num + 1; } const num = 2; increment(num); console....