• 函数


    1 x=function(){}
    2 x.a={};       //函数有属性????3 console.log(typeof x);  //function
    4 console.log(typeof x.a);  //object

    函数实际上是一个对象,每个函数都是Function类型的实例,而且都与其他引用类型一样具有属性和方法

     1 function sayName(name){
     2     alert(name);
     3 }
     4 function sum(num1,num2){
     5     return num1+num2;
     6 }
     7 function sayHi(){
     8     alert("Hi");
     9 }
    10 console.log(sayName.length);   //1
    11 console.log(sum.length);    //2
    12 console.log(sayHi.length);   //0

    每个函数都包含两个属性:length和prototype。其中length属性表示函数希望接收的命名参数的个数

  • 相关阅读:
    js中replace的正则替换
    ios沙盒路径
    Android开源框架
    小知识点
    __NSCFConstantString && __NSPlaceholderDictionary
    iq 格式分析
    C 函数
    Xcode报错
    XMPP Server
    H5网站借鉴
  • 原文地址:https://www.cnblogs.com/positive/p/3449942.html
Copyright © 2020-2023  润新知