Skip to content

Instantly share code, notes, and snippets.

@youxiachai
Created June 1, 2014 08:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save youxiachai/00659d1dd3fe557fcd61 to your computer and use it in GitHub Desktop.
Save youxiachai/00659d1dd3fe557fcd61 to your computer and use it in GitHub Desktop.
不用循环构建任意初始值数组
var a = Array.apply(null, {length : 10}).map(function () {
return 'a'
})
var b = new Array(10).join(',').split(',').map(function(){return 'b'});
@youxiachai
Copy link
Author

就效率而言..还是用循环最好....以上两个方法,相比循环在性能上差了一个数量级...果然..好玩的代码..效率都不行..

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment