zoukankan      html  css  js  c++  java
  • 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;
    }  
  • 相关阅读:
    01背包
    manacher马拉车算法
    盒子放球的DP
    Children’s Queue
    抽象类_作为接口
    斯特林数
    欧拉路HDU3018
    2019 SDN上机第三次作业
    第05组 Alpha冲刺(2/4)
    Alpha冲刺(1/4)
  • 原文地址:https://www.cnblogs.com/hello-web/p/6663742.html
Copyright © 2011-2022 走看看