TomatoYuyuko
V2EX  ›  问与答

小白求问 js 一个函数的入参也是一个带入参的函数该怎么写?

  •  
  •   TomatoYuyuko · Apr 19, 2018 · 1393 views
    This topic created in 2988 days ago, the information mentioned may be changed or developed.

    var a = "111"; var foo = function(arg){//todo}; function(foo){//todo};

    3 replies    2018-04-19 17:30:05 +08:00
    noe132
        1
    noe132  
       Apr 19, 2018 via Android
    a = (cb) = cb('hi')

    a((word) => console.log(word))

    js 不能限制传入函数的参数。

    如果要类型检查,可以用 typescript 或者 flow
    noe132
        2
    noe132  
       Apr 19, 2018 via Android
    第一行写错了,应该是
    a = (cb) => cb('hi')
    rabbbit
        3
    rabbbit  
       Apr 19, 2018
    没太看懂,不知道是不是这个意思
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   1458 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 38ms · UTC 16:48 · PVG 00:48 · LAX 09:48 · JFK 12:48
    ♥ Do have faith in what you're doing.