/**
* @param {number} x
* @param {number} y
* @return {number}
*/
var hammingDistance = function(x, y) {
return (x ^ y).toString(2).replace(/0/g, '').length;
};
Javascript one line solution

That's a nice use of the length property
For reference, here are a couple other oneline JavaScript solutions, along with the above, as well as their runtimes:
// 135ms 16.23% return [... (x ^ y).toString (2)].map ((x) => parseInt (x)) . reduce ((acc, x) => acc + x) //125ms 27.36% return (x ^ y).toString (2) . replace (/0/g, '') . length // 105ms 67.88% return [... (x ^ y).toString (2)].filter ((c) => c === '1') . length

This was my first attempt. Definitely not an optimal solution. It's always interesting to compare first attempts to attempts done on iteration.
/** * @param {number} x * @param {number} y * @return {number} */ var hammingDistance = function(x, y) { const numberToBinaryString = input => (input >>> 0).toString(2) const zeroFillNumberString = (padding, input) => "0".repeat(padding) + input let hammingDistance = 0 x = numberToBinaryString(x) y = numberToBinaryString(y) const padding = Math.abs(x.length  y.length) if(x.length < y.length) x = zeroFillNumberString(padding, x) else y = zeroFillNumberString(padding, y) for(i in x) hammingDistance += x[i] ^ y[i] return hammingDistance }
Edit: In the future, I will avoid looking at solutions before submitting my working solution. I would have loved to see how I optimized my approach.