Comments (1)
function flat(arr, depth = 1) {
return depth > 0 ?
arr.reduce((pre, cur) => {
return pre.concat(Array.isArray(cur) ? flat(cur, depth - 1) : cur);
}, []) :
arr.slice();
}
from blog.
Related Issues (20)
- 10. 实现一个GreetRobot,使之具有以下能力 HOT 1
- 11. 实现promise.all方法 HOT 1
- 12.实现一个eventBus HOT 1
- 13. 大数相加 HOT 1
- 14. 实现中间件的挂载(compose函数) HOT 1
- 15. 根据传入的姓名权重信息,返回随机的姓名(随机概率依据权重) HOT 1
- 16. 实现Object.is()方法 HOT 1
- 17. 实现一个对象的`flatten`函数,满足如下需求 HOT 1
- 18. 实现`set`方法,满足下面功能 HOT 2
- 19. 给定一组无序整数数组,找出小于target的元素个数,求最优时间复杂度
- 19. 列表转树结构 HOT 1
- 20. 如何实现koa的compose函数 HOT 1
- 21.实现异步任务并发量(JS + Promsie) HOT 1
- 22. 请实现一个 promisify 函数 HOT 1
- 4. 实现千分位的format函数 HOT 1
- 5. 实现call、bind、apply方法 HOT 1
- 7. 用reduce实现map函数 HOT 1
- 8. 实现一个带并发控制的异步调度器,保证同时运动的任务最多有两个 HOT 1
- 9. 实现一个Queue类 HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from blog.