https://stackoverflow.com/a/15106541/10757573
In this thread, the solution uses the following code:
var randomProperty = function (obj) {
var keys = Object.keys(obj)
return obj[keys[ keys.length * Math.random() << 0]];
};
In the comments from the answer, one user explained the bitwise shift as:
It's more as a shorthand of
parseInt(keys.length * Math.random(), 0)
Can anyone explain how the bitwise shift left 0 is the same as parseInt, or how it works in general, please?
I'm using this syntax, and it works well, but I don't understand what it's doing.