Generates a random mobile phone number with customizable prefix.

Creates a mobile phone number in the format: [prefix][3-4 digits][4 digits]. The middle section is 3 digits if the random number is less than 1000, otherwise 4 digits. The last section is always 4 digits, zero-padded if necessary. Commonly used for generating Korean mobile phone numbers or similar formats.

  RandomGenerator.mobile();        // "0103341234"
RandomGenerator.mobile("011"); // "0119876543"
RandomGenerator.mobile("+82"); // "+8233412345"

// Generate test user phone numbers
const testUsers = Array.from({ length: 100 }, () => ({
name: RandomGenerator.name(),
phone: RandomGenerator.mobile(),
altPhone: RandomGenerator.mobile("011")
}));

// Create international phone numbers
const internationalPhone = RandomGenerator.mobile("+821");

// Generate contact list for testing
const contacts = ["010", "011", "016", "017", "018", "019"].map(prefix => ({
carrier: prefix,
number: RandomGenerator.mobile(prefix)
}));
  • Parameters

    • prefix: string = "010"

      The prefix string for the phone number (default: "010")

    Returns string

    A formatted mobile phone number string