点击运行
function createArray(length: number, value: any): Array
{ let result = []; for (let i = 0; i < length; i++) { result[i] = value; } return result; } console.log(createArray(3, 'x')); // ['x', 'x', 'x']
运行结果 :
正在执行...