Blogger Information
Blog 30
fans 1
comment 0
visits 24318
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
JavaScript基础 20191021
阿乎乎的学习
Original
689 people have browsed it

实例

<!doctype html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport"
          content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>JS演示</title>
</head>
<body>
<script>
    // alert('弹窗提示');
    //使用var关键字来定义变量
    var name='小新';
    console.log('我的名字是'+name);
    //字符串类型
    console.log(typeof(name));
    //数组类型
    var name1=['小新','小白','小黑'];
    console.log(typeof(name1));
    console.log(name1);
    //对象
    var obj=new Object();
    console.log(obj);
    //数值类型
    var sum1=10;
    console.log(typeof(sum1));
    var sum2=5;
    var sum=sum1+sum2;
    console.log(sum1+'+'+sum2+'='+sum);
    //js表达式
    if(sum1<sum2){
        console.log(sum1+'比'+sum2+'小');
    }else{
        console.log(sum1+'不比'+sum2+'小');
    }
    //js定义函数的方法,
    function Sum(num1,num2){
        return num1*num2;
    }
    var num=Sum(10,20);
    console.log(num);

    var ls=function (num3,num4){
        return num3+num4;
    }
    console.log(ls(15,22));
</script>
</body>
</html>

运行实例 »

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

简单的学习了JavaScript的变量定义,数据类型,以及定义函数的方法

Correction status:qualified

Teacher's comments:js的基础并不多的, 多写多看一定能学会的
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