6. 数组练习
(1) 打印对象⾥数组的⻓度
console.log(result.list.length)
(2) 打印最后数组最后⼀个成员的所有属性值
var len = result.list.length;
var item = result.list(len-1);
最后一个数组的所有对象:console.log(item.categoryId);
console.log(item.name);
console.log(item.iconUrl);
var result = {
“code”: 666,
“msg”: “success”,
“list”: [{
“categoryId”: 145,
“name”: “时令鲜果”,
“iconUrl”: “/img/fresh/other/r1.png”
}, {
“categoryId”: 243,
“name”: “海鲜⽔产”,
“iconUrl”: “/img/fresh/other/r2.png”
}, {
“categoryId”: 279,
“name”: “家禽蛋”,
“iconUrl”: “/img/fresh/other/r3.png”
}, {
“categoryId”: 346,
“name”: “地⽅农产”,
“iconUrl”: “/img/fresh/other/r4.png”
}, {
“categoryId”: 436,
“name”: “百果园公司”,
“iconUrl”: “/img/fresh/other/r5.png”
}, {
“categoryId”: 357,
“name”: “农品茗茶”,
“iconUrl”: “/img/fresh/other/r6.png”
}, {
“categoryId”: 6,
“name”: “五⾕杂粮”,
“iconUrl”: “/img/fresh/other/r7.png”
}, {
“categoryId”: 311,
“name”: “⽜⽺⾁”,
“iconUrl”: “/img/fresh/other/r8.png”
}]
}
1. 数据类型有哪⼏种(提问)
问题一回答:
1:string字符串 2:boolean布尔值 3:object对象(数组函数) 4:null 对象的一种特殊类型
5:undifined 6:number数字类型
2. 什么时候数据类型会是 undefined?
问题儿回答
1:声明了变量但未设置初始值(赋值)
3. 字符串有哪⼏种形式,⼀般⽤那种?
问题三回答
“” '' ``(模板字符串)
推荐用单引号
4. 常⻅的数字有哪些?
问题四回答
整数⼩数最⼤值和最⼩值
5. var obj = {name: '王菲', age: 40} ,⽤两种⽅式在控制台打印属性值 name 的值
用.点出来 也可以用中括号加单引号['']