zoukankan      html  css  js  c++  java
  • JS 函数—length & prototype

     JS中的函数也是对象,因此有属性和方法。每个函数都有两个属性:length和prototype。

    ①length属性保存函数定义的命名参数的个数,如下:

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

     ②prototype属性保存引用类型所有实例方法的地方,这意味着toString()、valueOf()等方法实际上都保存在prototype上,进而由所有实例共享。

  • 相关阅读:
    windows环境下ElasticSearch6 安装head插件
    画流程图挺好的软件---visio
    Spring AOP使用注解记录用户操作日志
    通用mapper版+SpringBoot+MyBatis框架+mysql数据库的整合
    chrony 时间同步服务器
    Python面试题
    新认知丨认知信念决定学习能力
    Ubuntu18、Ubuntu16、Ubuntu14更新源
    让人头疼的时候最有创造力
    安卓学习(2)
  • 原文地址:https://www.cnblogs.com/codexlx/p/14335375.html
Copyright © 2011-2022 走看看