Skip to content

randomKey

Subhajit Sahu edited this page Dec 8, 2022 · 1 revision

Pick an arbitrary key.

Similar: keys, has, randomKey.
Similar: keys, values, entries.


function randomKey(x, fr)
// x:  an object
// fr: random number generator ([0, 1))
const object = require('extra-object');

var x = {a: 1, b: 2, c: 3};
object.randomKey(x);
// → 'c'

object.randomKey(x);
// → 'b'


References

Clone this wiki locally