Js注释和对象
1.注释
单行: //注释内容
console.log('加油~');//在控制台输出一条信息;
多行: /*注释内容*/;
2.对象
1)对象是一个复合值,是根据某种引用类型创建出来的实例。
2)常见数据引用类型:
*Object
~创建Object类型实例并为Object对象赋值:
var $1 = new Object(); $1.name='yw'; $1.age=27; $1.sex='男'; $1.isAdult=true;
~其他方式创建实例及赋值:
var $2={ name:'zrh', age:18, sex:'女', isAdult:false };
3)for in迭代
var $1 = new Object(); var $2={ name:'zrh', age:18, sex:'女', isAdult:false }; for(var i in $2){
console.log(i); console.log($2[i]); }
效果如下图:
God, Grant me the SERENITY, to accept the things I cannot change,
COURAGE to change the things I can, and the WISDOM to know the difference.