它源于群里的某一题目:
有一个数n=5,不用for循环,怎么返回[1,2,3,4,5]这样一个数组
群的“糖果男孩”给的答案:
function getArr(n) {
var a = [],
b = [],
m = 0;
a.length = n + 1;
a.toString().replace(/,/g, function () {
b.push(++m);
});
return b;
}
Statement:The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn