JS的find()
来源:互联网 发布:ubuntu 16.04软件下载 编辑:程序博客网 时间:2024/06/06 09:38
ES6的find函数出现之前,我们是这样写的:
const persons= [ { name: 'Judy', sex: 'Female'}, { name: 'Tom', sex: 'Male'}, { name: 'Grace', sex: 'Female'},]function findPerson(name,sex) { for(let i = 0; i<persons.length; ++i) { if(persons[i].name=== name&& persons[i].sex === sex) { return persons[i]; } }};findPerson('Judy','Female');有了find之后,我们只需要这样写就行了:person= persons.find(person => person.name ==='Judy' && pet.sex === 'Female');console.log(pet); // {name: "Judy", sex: "Female"}
阅读全文
0 0
- JS的find()
- js array.find()扩展
- Jquery的filter,not,find和JS中的split,join
- node.js项目的Cannot find module ‘xxx’问题
- js jq中$().eq()和$().find()的用法
- Node.js cannot find module ***
- js -- can not find module
- sublime某些插件出现'Node.js was not find ...' 的解决方法
- loopback安装教程--Node.js Cannot find Module xxx 的问题
- 安装node.js和npm推荐版本的报错 can't find the npmlog file
- Node.js文件上传的时候控制台报Error: Cannot find module 'formidable'
- Node.js Cannot find module 'xxx' 问题解决
- Node.js Cannot find module 'mysql'
- node.js cannot find module "xxx"解决方法
- vue.js:[Vue warn]: Cannot find element:
- Cannot find module '.tmp/Rx.min.js'
- Node.js报错cannot find module
- find -exec 与 find - xargs 的差别
- 【使用Postman测试web接口】Postman的安装与入门
- jstree在chrome浏览器中显示的排序与其他浏览器(firefox,IE)显示不一致
- 怎样才能赚到钱系列(六)
- C++ 从Dll中导出类
- Vue 2.5 发布
- JS的find()
- 2017-11-06 ~ 2017 11-10 八连测酱油记
- 详解java String
- MySQL基本操作
- Go实战--也许最快的Go语言Web框架kataras/iris初识四(i18n、filelogger、recaptcha)
- 全面、易懂的Webview使用详解
- linux 逻辑卷管理 调整分区大小
- China love基金会全力支持CHNLOVE选拔活动
- ABP框架---EF code First 数据迁移