I always had this question:
When i dont mind the exact floating number
Which one is preferred?
someValue = parseFloat(el.outerWidth())+parseFloat(ele2.css("marginRight")),
someValue = parseInt(el.outerWidth(), 10)+parseInt(ele2.css("marginRight"), 10),
Which method is easier for the JS engine?
It's as broad as it's long really. parseFloat
is pointless here because the values will always be integers. I'd rather save on bytes and use the unary operator +
:
someValue = (+el.outerWidth())+(+ele2.css("marginRight"));