1256700
调试 JS 的时候发现某些位置很意外地颠倒了顺序,
我存了一个全局变量 store, 每次把 store 存在 history 里边,
那么我觉得 history 里不去操作是不会改变了, 但是.. 却变了.
图片当中第一次查看 history 的最后一项, 第二次的倒数第二项 1 位置发生了颠倒..
图片加载失败的话在这里: http://huaban.com/pins/6503638/zoom/
说到颠倒数组, 我的确有 reverse(store) 这样对 store 进行操作的, 但不该有影响啊.
下面是往 history 数组存储 store 的代码.. 我也试过加 store.concat() , 没效果..
完整在: https://github.com/jiyinyiyong/code_blocks/blob/gh-pages/convert.coffee
editor_mode = on
store = ['\t']
history = [store]
current = 0
history_make = (store) ->
history = history[..current]
console.log ":::", store
history.push store
console.log "###", history[history.length-1]
current+= 1
socket.emit 'sync', store if socket?
window.onload = ->
box = tag 'box'
window.focus()
refresh = (store) ->
console.log store
box.innerHTML = draw store
history_make store.concat()
实在闹不明白是怎么改变掉的.. 求助啊.