UNPKG

xxm-test-js

Version:

xxm-js通用js工具(utils)库

23 lines 719 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.arrayToString = arrayToString; /** * 将数组转换为字符串。 * * @template T 数组元素的类型。 * * @param {T[]} array - 要转换的数组。 * @param {string} [separator=','] - 自定义连接符,默认为 ','。 * @returns {string} 转换后的字符串。 * * @example * const numbers = [1, 2, 3, 4]; * const result = arrayToString(numbers, '-'); // 结果: "1-2-3-4" * * const words = ['Hello', 'World']; * const result2 = arrayToString(words); // 结果: "Hello,World" */ function arrayToString(array, separator = ',') { return array.join(separator); } //# sourceMappingURL=arrayToString.js.map