While passing parameter to function, there are two ways to pass and i'm not sure about which one is better?
First one is:
const foo = (bar) => bar;
number = 3.4567;
foo(number.toFixed(2));
Second one is:
const foo = (bar) => bar;
number = 3.4567;
fixedNumber = number.toFixed(2);
foo(fixedNumber);
It is basically the same but in the second one you define a new variable for fixedNumber
, thus making your code more readable for other developers.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.