推荐关注
Meteor
JSLint - a JavaScript code quality tool
jsFiddle
D3.js
WebStorm
推荐书目
JavaScript 权威指南第 5 版
Closure: The Definitive Guide
raighne

JavaScript 如何理解函数参数

  •  
  •   raighne · Dec 28, 2016 · 2498 views
    This topic created in 3448 days ago, the information mentioned may be changed or developed.

    项目里定义了这么一个函数: test = function (one, two, three, four, five, six){}里面有六个参数。

    然后调用的时候 test(one,two,function(){}.function(){},true){}只有两个对应的参数,然后是两个函数,最后一个 true 怎么理解这里面的函数,还有最后一个 true 呢

    6 replies    2016-12-28 16:08:58 +08:00
    mcfog
        1
    mcfog  
       Dec 28, 2016 via Android   ❤️ 1
    我不理解你不理解什么
    raighne
        2
    raighne  
    OP
       Dec 28, 2016
    @mcfog 定义的是 6 个参数,调用的时候只有五个,然后后面三个前面两个函数,后面一个 true ,分别对应的啥
    Sivan
        3
    Sivan  
       Dec 28, 2016
    @raighne 后面的两个函数和 true 分别对应 three , four , five 。你的调用里 six 是 undefined 。
    Jeepeng
        4
    Jeepeng  
       Dec 28, 2016   ❤️ 1
    one=one
    two=two
    three = function(){}
    four=function(){}
    five=true
    six=undefined
    xcatliu
        6
    xcatliu  
       Dec 28, 2016   ❤️ 1
    函数可以作为参数传递,也可以作为返回值。
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   5649 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 61ms · UTC 06:42 · PVG 14:42 · LAX 23:42 · JFK 02:42
    ♥ Do have faith in what you're doing.