Read Arduino from JavaScript

Hi, Im just looking for a simple example of how I might poll an arduino, with an accelerometer, from within the game loop of a javascript program. Basically I'm wanting to swing a physical bat to swing a bat in-game. Thanks!

Is there a network connection between the application that is hosting the javascript, and the Arduino? If so, design a protocol between the two that meets your bandwidth/latency requirements. For example, you might choose to run a long-running query over HTTP.