Skip to content

Instantly share code, notes, and snippets.

@zythum
Created January 17, 2014 17:13
Show Gist options
  • Save zythum/8477316 to your computer and use it in GitHub Desktop.
Save zythum/8477316 to your computer and use it in GitHub Desktop.

Revisions

  1. zythum created this gist Jan 17, 2014.
    16 changes: 16 additions & 0 deletions 如果这样的计数还准么?.coffee
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,16 @@
    #i用户统计点击了多少次页面, 产经理最喜欢统计数据了
    i = 0;
    document.body.addEventListener 'click', ()-> console.log ++i


    # 很简单的数值交换函数 o.prop1 <=> o.prop2
    _switch = (o, prop1, prop2)->
    #`var i`
    i = o[prop2]
    o[prop2] = o[prop1]
    o[prop1] = i
    o;

    a = p1: '1', p2: '2'

    _switch a, 'p1', 'p2'