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

妈妈说好代码要分享-js

  •  
  •   Debiancc · Nov 5, 2014 · 4787 views
    This topic created in 4391 days ago, the information mentioned may be changed or developed.
    //shortcut support. arrow-up arrow-down and enter event.
    if (event.which == keyMap.down || event.which == keyMap.up) {
    var direction = event.which == keyMap.down ? true : false,
    $activeSelector = $('.wcSingleUser.active'),
    $tmpSelector;

    //if current active selector has next or prev element and direction is matching
    //then execute switch active and keep unique
    if (((!!($tmpSelector = $activeSelector.next()) && direction)
    || (!!($tmpSelector = $activeSelector.prev()) && !direction))
    && $tmpSelector.length) {
    $activeSelector.removeClass('active');
    $tmpSelector.addClass('active');
    }
    return;
    }


    太美
    8 replies  •  2014-11-10 10:37:42 +08:00
    Jaylee
    Jaylee
    Nov 5, 2014
    1
    你想表达什么 ?
    cdxem713
    cdxem713
    Nov 5, 2014
    2
    函数名是个啥,变量声明不放在函数头么?
    neutrino
    neutrino
    Nov 5, 2014
    3
    @cdxem713 用的时候再声明变量是好习惯。
    cdxem713
    cdxem713
    Nov 5, 2014
    4
    @neutrino js由于变量提升,其实在哪声明都跟在函数头声明是一样的,在函数头声明会安全些。用时重新初始化。
    vose
    vose
    Nov 6, 2014
    5
    js 新手,不要脸问一下……这段函数是干嘛用?亮点是? 我也想体会一下呀,教练!
    cmy5001
    cmy5001
    Nov 6, 2014
    6
    不明觉厉,简单两个判断可以完成的事,非要绕一大圈,这是逼格的体现?
    Debiancc
    Debiancc
    OP
    Nov 10, 2014
    7
    @cmy5001 对的
    Debiancc
    Debiancc
    OP
    Nov 10, 2014
    8
    @vose 目测下来是一个快捷键的support
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Privacy   ·   Solana   ·   1191 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 51ms · UTC 17:47 · PVG 01:47 · LAX 09:47 · JFK 12:47
    ♥ Do have faith in what you're doing.