SOURCE

'use strict';
//字符串
// var s='hello world';
// console.log(s.length);
// console.log(s.toUpperCase());
// console.log(s.indexOf('d'));

//数组
// var ar = new Array(1,2,5,6);
// console.log(ar.pop());

//对象
// var xiaoming = {
//     name : '小明',
//     age : 18,
//     sex : 'male'
// };
// console.log(xiaoming.name);
// console.log(xiaoming['name']);
// console.log(xiaoming.school='jcxy');
// name in xiaoming;
// for ( var i in xiaoming){
//     console.log(`${i} : ${xiaoming[i]}`);
// }

// var o = {
//     name: 'Jack',
//     age: 20,
//     city: 'Beijing'
// };
// o.sex='nan'
// console.log(o)
// delete o.sex;
// console.log(o)
// var height = parseFloat(prompt('请输入身高(m):'));

//遍历对象
var o = {
    name: 'Jack',
    age: 20,
    city: 'Beijing'
};
for (var r in o) {
    if (o.hasOwnProperty(r)) {
        console.log(`${r}:${o[r]}`)
    }
}

//遍历数组
var a = ['A', 'B', 'C'];
for (var key in a) {
    console.log(`a[${key}]:${a[key]}`);
}
// for ... in对Array的循环得到的是String而不是Number
var i;
for (i = 0; i < a.length; i++) {
    console.log(`a[${i}]:${a[i]}`);
}
console 命令行工具 X clear

                    
>
console