I need to round numeric values for properties of a given object. The following code works fine, but I am concerned if there is a way to make it faster.
I am targeting latest Chrome and Firefox.
http://jsbin.com/bahedegoni/edit?html,output
window.app = {
start: function () {
var cmd = {
a: 11.12,
b: 0.29,
c: 'x',
d: 'y'
};
Object.keys(cmd).forEach(function (prop) {
if (typeof cmd[prop] === 'number') {
cmd[prop] = Math.round(cmd[prop]);
}
}.bind(this));
console.log(cmd);
}
};
cmd
, though? \$\endgroup\$