首页
学习
活动
专区
圈层
工具
发布
社区首页 >专栏 >jQuery 练习题(3) -- 遍历数组对象

jQuery 练习题(3) -- 遍历数组对象

作者头像
用户7293182
发布2022-01-17 21:21:32
发布2022-01-17 21:21:32
7420
举报
文章被收录于专栏:jQuery每日经典jQuery每日经典

上期(windows右键菜单设置位置)可以这样实现:

1. 常规 if - else if (x<50) { location.left = x; } else { location.right = x; } 2. 三目运算符 location[ x<50 ? 'left' : 'right' ] = x; 3. 布尔值加法 location[ ['right', 'left' ] [+(x<50)] ] = x;

本期题目

遍历对象数组,找出 ID = 1 的 子对象。

数组如下:

var testData = [

{id: 1,port: 'Tomhua(亚历山大港)', time:'2016-10', infact:1531, inrange:9156, export:28989, totalImport:13621},

{id: 1,port: 'Tomhua(亚历山大港)', time:'2016-11', infact:4153, inrange:34615, export:89894, totalImport:45234},

{id: 2,port: 'Namibe(木萨米迪亚)', time:'2016-10', infact:35612, inrange:6515, export:26648, totalImport:45132},

{id: 2,port: 'Namibe(木萨米迪亚)', time:'2016-11', infact:1561, inrange:8651, export:66484, totalImport:13241},

{id: 3,port: 'Bentiaba(本蒂亚巴)', time:'2016-10', infact:8413, inrange:24841, export:65311, totalImport:34545},

{id: 3,port: 'Bentiaba(本蒂亚巴)', time:'2016-11', infact:41484, inrange:1148, export:53114, totalImport:46486},

{id: 4,port: 'Lucira(卢西拉)', time:'2016-10', infact:6648, inrange:2664, export:84135, totalImport:37645},

{id: 4,port: 'Lucira(卢西拉)', time:'2016-11', infact:5266, inrange:4526, export:41351, totalImport:45915}

]

本文参与 腾讯云自媒体同步曝光计划,分享自微信公众号。
原始发表:2017-04-08,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 jQuery每日经典 微信公众号,前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体同步曝光计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档