2015-10-02 54 views
0

這是整個功能:在幫助中左手無效?

$(document).keyup(function(e) { 
     delete game.keys[e.keyCode ? e.keyCode : e.which] = true; 
    }); 

這是引發錯誤行:

delete game.keys[e.keyCode ? e.keyCode : e.which] = true; 

非常新的JavaScript,請幫助。

+0

https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/delete –

+2

刪除'= TRUE; – Tushar

回答

0

無需等於true:

delete game.keys[e.keyCode ? e.keyCode : e.which]; 
1

使用時您需要事後給一些變量deletedelete someVar。使用=delete中執行任務是無效的。所以刪除= true

delete game.keys[e.keyCode ? e.keyCode : e.which];