Function strToNum

  • Checks the provided array or object's string formatted values and converts them to numbers.

    Parameters

    • data: Object | any[]

      The array or object to be converted.

    • str: string[]

      The key names separated by commas indicating which values in the object should be converted to numbers. (optional)

    Returns Object | any[]

    • The converted array or object.

    Example

    strToNum(["3","4",3,"7",8]);
    // Output: [3, 4, 3, 7, 8]

    strToNum({ a:2, b:"4", c:"5" }, "c,b");
    // Output: { a: 2, b: 4, c: 5 }

Generated using TypeDoc