# random

# number([options])

Generates random number

TIP

Param Type Default
options mixed {min: 0, max: 99999, precision: 1}

NOTE 1: passing a number as the param will set the max value to that number and use the min and precision defaults

NOTE 2: Starting from v5.5.0 faker.datatype.number is more preferred to use

faker.random.number(); // 58199
faker.random.number(55); // 11
faker.random.number({min:10}); // 86801
faker.random.number({min: 10, max: 100}); // 53
faker.random.number({min: 10, max: 100, precision: .25}); // 33.5

# arrayElement([array])

Takes an array and returns a random element of the array

TIP

Param Type Default
array array ["a", "b", "c"]
faker.random.arrayElement(); // b
faker.random.arrayElement(['bob', 'was', 22]); // 22

# objectElement([object[, field]])

Takes an object and returns a random element of the array

TIP

Param Type Default
object object { "foo": "bar", "too": "car" }
field mixed undefined
faker.random.objectElement(); // car
faker.random.objectElement({ name:'bob', color: 'blue', age: 22}); // bob
faker.random.objectElement({ name:'bob', color: 'blue', age: 22}, 'key'); // name

# uuid

Returns random UUID

TIP

NOTE: Starting from v5.5.0 faker.datatype.uuid is more preferred to use

faker.random.uuid(); // 202e301c-1a22-4ed9-8f86-88e5520a76c6 

# boolean

Returns random boolean

TIP

NOTE: Starting from v5.5.0 faker.datatype.boolean is more preferred to use

faker.random.boolean(); // true 

# word

Returns random word from faker methods that can generate words

faker.random.word(); // compress 

# words([count])

return random number of words from faker.random.word

TIP

Param Type Default
count number 1 or 2 or 3
faker.random.words(); // eco-centric
faker.random.words(4); // neural wireless Borders invoice

# image

alias to faker.image.image()

faker.random.image() // http://lorempixel.com/640/480/city

# locale

Return random locale. See Localization for more info

faker.random.locale() // nl

# alphaNumeric

return a random alpha numeric

TIP

Param Type Default
count number 1
faker.random.alphaNumeric(); // p
faker.random.alphaNumeric(4); // 81bh