美文网首页
6.1 Function.prototype.length

6.1 Function.prototype.length

作者: 牧羊少年之奇幻之旅 | 来源:发表于2018-11-03 13:52 被阅读0次

参考以下文章学习:
1. Function.length - MDN

length 属性指明函数的形参(formal parameters)个数,length 是函数对象的一个属性,指该函数有多少个必须要传入的参数,即形参的个数,形参的数量不包括 rest parameter。仅包括第一个具有函数参数默认值的参数之前的参数个数。与之对比的是,arguments.length 是函数被调用时实际传参的个数。

Function.prototype.length 属性的属性描述符:

propertyDescriptor.png
var cl = console.log;

cl(Function.length); // expected output: 1
cl((function () {}).length); // expected output: 0
cl((function (a) {}).length); // expected output: 1
cl((function (a, b) {}).length); // expected output: 2 etc.

cl((function (...rest) {}).length); // expected output: 0. rest parameter is not counted;
cl((function (a, b = 1, c) {}).length); // expected output: 1. only parameters before the first one with a default value is counted

相关文章

  • 6.1 Function.prototype.length

    参考以下文章学习:1. Function.length - MDN length 属性指明函数的形参(formal...

  • 最悲惨的儿童节

    曾约定6.1放风筝 曾约定6.1踏青 曾约定6.1去小吃街 曾约定6.1逛街购物 曾约定6.1去游乐场 曾约定……...

  • 200期第二个月的晨间日记 2018年6月

    6.1号手术,6.1-6.5之间没有晨间日记

  • 六一儿童节

    6.1

  • python生物信息学数据管理:自测题

    6.1

  • Excel实战:累计求和

    本篇适合:有一定公式基础者。 如图-1,需求是累计求和,其逻辑为: 6.1累计=6.1 6.2累计=6.1+6.2...

  • Day - 29 (5.26)

    临摹。 (6.1)

  • 6.1

    前几天宝贝问我,妈妈6.1放不放假呀,我说周五不放假,宝贝说不放假还算什么就一。不放假还能算过节吗? 所以今天没有...

  • 6.1

    晚上也要好好接电话。 看到一个陌生电话,第一个念头是不想接。接起那端却是一个关切好听的男低音,提醒我车窗没关。赶忙...

  • 6.1

    今天是小朋友的节日,所以早上早早的把妞叫醒,因为昨天答应她要去妈妈的学校,所以她很麻溜的起床,喝牛奶,迅速搞定。来...

网友评论

      本文标题:6.1 Function.prototype.length

      本文链接:https://www.haomeiwen.com/subject/zchxxqtx.html