Blogger Information
Blog 10
fans 1
comment 0
visits 8994
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
while循环和对象字面量
枫的博客
Original
987 people have browsed it
<script>
    // 写一个while循环, 输出一个数值数组所有的奇数
    var arr1=[1,2,3,4,5,6,7,8,9];
    var i=0;
    while(i<arr1.length){
        if(arr1[i]%2!==0){
            console.log(arr1[i])
        }
        i++
    }
//    写一个对象字面量, 描述一款你喜欢的手机信息
    var obj={
        phone:'小米',
        price:39000,
        nuber:10,
        sum:function () {
           return  '当前数量为'+this.nuber+','+this.phone + '一共的价格是'+this.price
        }
    }
    console.log(obj.sum())
//    写一个函数表达式, 计算三个数之和
    //函数表达式,又称为匿名函数,即函数名匿藏起来,用变量名表示
    var stu =function (x,y,z) {
        return  x+y+z;
    };
    console.log(stu(10,20,30))
</script>


Correction status:Uncorrected

Teacher's comments:
Statement of this Website
The copyright of this blog article belongs to the blogger. Please specify the address when reprinting! If there is any infringement or violation of the law, please contact admin@php.cn Report processing!
All comments Speak rationally on civilized internet, please comply with News Comment Service Agreement
0 comments
Author's latest blog post