博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
[Javascript] Intro to Recursion
阅读量:7157 次
发布时间:2019-06-29

本文共 802 字,大约阅读时间需要 2 分钟。

Recursion is a technique well suited to certain types of tasks. In this first lesson we’ll look at solving a problem that requires the flattening of arrays without using recursion. Showing the shortcoming of a non-recursive solution first will help you to understand why it’s so valuable and why sometimes it's the only solution to many problem.

 

let input, config, tasks;input = ['dist'];config = {  "dist": ["build", "deploy"],  "build": ['js', 'css', 'vender'],  "js": ['babel', 'ng-Annotate', "uglify"],  "css": ["sass", "css-min"]};tasks = [];getTasks(input);function getTasks(input){    input.forEach((task)=>{    if(config[task]){      getTasks(config[task]);    }else{      tasks.push(task);    }  })};console.log(tasks);

 

["babel", "ng-Annotate", "uglify", "sass", "css-min", "vender", "deploy"]

 

转载地址:http://spegl.baihongyu.com/

你可能感兴趣的文章
spring-mvc.xml 和 application-context.xml的配置与深入理解
查看>>
定时器
查看>>
html5-output的用法
查看>>
宝塔linux
查看>>
窗体容器
查看>>
sql向表中添加字段
查看>>
【react native】rn踩坑实践——从输入框“们”开始
查看>>
【react-native】持续踩坑总结
查看>>
diango-团队介绍
查看>>
zendframework 2 链接数据库
查看>>
汇编心得(一)在32位机上实现64位数的相加
查看>>
BestCoder Round #50 (div.1) 1003 The mook jong (HDU OJ 5366) 规律递推
查看>>
sql 中常见的控制流语句
查看>>
百度地图API实现地图定位
查看>>
python mysqlDB
查看>>
Java课堂笔记第七次407
查看>>
[LeetCode] Different Ways to Add Parentheses
查看>>
SqlBulkCopy类 基本使用方法
查看>>
OC 截取字符串
查看>>
ES查看配置和查看全部配置
查看>>