Blogger Information
Blog 16
fans 0
comment 0
visits 12551
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
5.6学习使我快乐
如花似玉的小牛牛的博客
Original
533 people have browsed it

实例

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>作业1</title>
    <script>
    var $user=[1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16];
var i=0;
while (i<$user.length) {            //循环开始,如果(i<$user的内容长度),也说明了循环的次数。
    if ($user[i] % 2 !==0){         //如果数组的元素%2,余数不等于0,说明他是奇数。
        console.log($user[i]);      //在控制台输出数组中不包含偶数的元素。
        document.write($user[i]+ '<br/>') //在网页输出不包含数组元素偶数的数值。
    }
    
    i++;                                //每运行一次 i+1 

}
</script>
</head>
<body>
    
</body>
</html>

运行实例 »

点击 "运行实例" 按钮查看在线实例

实例

  var $phone= {
        phone: 'iphone xs max',
        cpu: 'A12',
        Screen_size: '1920*1080',
        other: good=function (var1,var2){
           return console.log('这是一个变量' + this.var1);
        }
    }

运行实例 »

点击 "运行实例" 按钮查看在线实例

实例

var num=function(x,y,z){
   var i=x+y+z;
   console.log('x+y+z=' + i);
   document.write('x+y+z=' + i)

};    //匿名函数 花括号末尾要加分号。

num(10,20,30);





//方法2:函数外部打印调用

var num=function(x,y,z){
   var i=x+y+z;
   return i;
};    //匿名函数 花括号末尾要加分号。

rep=num(10,20,30);    //把返回值赋值给一个变量,方便调用,不能直接调用函数内部局域变量。
console.log('x+y+z=' + rep);
document.write('x+y+z=' + rep +'<br/>');
document.write('x+y+z=' + num(11,12,13));

运行实例 »

点击 "运行实例" 按钮查看在线实例


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