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

JavaScript 如何理解函数参数

  •  
  •   raighne · Dec 28, 2016 · 2757 views
    This topic created in 3613 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
    mcfog
    Dec 28, 2016 via Android❤️1
    1
    我不理解你不理解什么
    raighne
    raighne
    OP
    Dec 28, 2016
    2
    @mcfog 定义的是 6 个参数,调用的时候只有五个,然后后面三个前面两个函数,后面一个 true ,分别对应的啥
    Sivan
    Sivan
    Dec 28, 2016
    3
    @raighne 后面的两个函数和 true 分别对应 three , four , five 。你的调用里 six 是 undefined 。
    Jeepeng
    Jeepeng
    Dec 28, 2016❤️1
    4
    one=one
    two=two
    three = function(){}
    four=function(){}
    five=true
    six=undefined
    xcatliu
    xcatliu
    Dec 28, 2016❤️1
    6
    函数可以作为参数传递,也可以作为返回值。
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Privacy   ·   Solana   ·   1204 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 30ms · UTC 23:38 · PVG 07:38 · LAX 15:38 · JFK 18:38
    ♥ Do have faith in what you're doing.