博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
用某个值快速填充数组_用顺序值填充数组
阅读量:2514 次
发布时间:2019-05-11

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

用某个值快速填充数组

I've been contributing to Mozilla's awesome DevTools debugger because, well, I want to give back to the Firefox Engineers and all the developers who have stayed loyal to Firefox.  Having my hand in loads of Mozilla projects is really satisfying, especially for my ego.

我一直在为Mozilla出色的DevTools调试器做出贡献,因为我想回馈Firefox工程师和所有忠于Firefox的开发人员。 参与Mozilla项目的工作真的很令人满意,特别是对于我的自我。

In any event, one task required me to fill an array with every number in a sequence, then I would filter out unwanted items based on another array.  Here's how you can fill a range within an array:

无论如何,一项任务需要我用序列中的每个数字填充一个数组,然后再根据另一个数组过滤掉不需要的项目。 您可以按照以下方法填充数组中的范围:

const fillRange = (start, end) => {  return Array(end - start + 1).fill().map((item, index) => start + index);};const allLines = fillRange(0, numLines - 1);// [0, 1, 2, 3, 4, 5, ...]

From there I could filter out what I didn't want:

从那里我可以过滤掉我不想要的东西:

let executableLines = [/* series of line numbers with code */];const emptyLines = allLines.filter(i => !executableLines.includes(i));

When the feature gets merged (...and no one complains about their Firefox debugger...) I'll share more about  my contribution!

当功能合并后(...没有人抱怨他们的Firefox调试器...),我将分享更多我的贡献!

翻译自:

用某个值快速填充数组

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

你可能感兴趣的文章
linux文件目录类命令|--cp指令
查看>>
.net MVC 404错误解决方法
查看>>
linux系统目录结构
查看>>
git
查看>>
btn按钮之间事件相互调用
查看>>
Entity Framework 4.3.1 级联删除
查看>>
codevs 1163:访问艺术馆
查看>>
冲刺Noip2017模拟赛3 解题报告——五十岚芒果酱
查看>>
并查集
查看>>
sessionStorage
查看>>
代码示例_进程
查看>>
Java中关键词之this,super的使用
查看>>
学习进度
查看>>
“此人不存在”
查看>>
github.com加速节点
查看>>
解密zend-PHP凤凰源码程序
查看>>
python3 序列分片记录
查看>>
Atitit.git的存储结构and 追踪
查看>>
atitit 读书与获取知识资料的attilax的总结.docx
查看>>
B站 React教程笔记day2(3)React-Redux
查看>>