• JS函数表达的几种写法


    arguments数组形式的  用于函数  比如不知道参数有多少个或者不固定那么用到arguments
    function show(){
    //alert(arguments.;length);
    alert(arguments[0]);
    }
    alert(show(12,3,4));//0角标是12
    (1)典型的函数声明

    function slide(arguments){

    //...code/
    }
    (2)以函数表达式的形式定义函数
    var slide = function(arguments){
    //...code
    }
    他们有所区别:例子二是赋值给了一个变量
     
    var slide=new Object(){
    //...code
    }
    个人理解 构造函数是为了多个调用 配合this 
    例子:
    var b=a("我");
    console.log(b);
    function a(name){
    var student=new Object();
    student.name=name;
    student.sayHi=function(){
    console.log(this.name+"说大家好");
    }
    return  student;
    }  
  • 相关阅读:
    Beta版使用说明
    【每日scrum】NO.7
    【每日scrum】NO.6
    【每日scrum】NO.5
    【每日scrum】NO.4
    【每日scrum】NO.3
    【每日scrum】NO.2
    【每日scrum】NO.1
    运行及总结
    测试与调试
  • 原文地址:https://www.cnblogs.com/hello-web/p/6663742.html
Copyright © 2020-2023  润新知