The only differences in running in a VM vs running on a real machine that you may need to watch out for are actual hardware differences. A strength of using a VM is that all OS combinations will be running against the same virtual hardware - the same vanilla VGA "adapter", the same vanilla network "card", etc. For testing, though, that is also a liability, since it means you're not testing against real world hardware.
JavaScript running in the browser normally shouldn't care about your hardware, but there can be situations where artifacts may be observable. If your JavaScript makes use of advanced browser features like plugins, ActiveX controls, or display features like Flash, Silverlight, OpenGL, or Canvas or whatever, or things like video or audio playback, your code may be sensitive to hardware differences between machines that would not be apparent when testing exclusively in homogeneous VMs. Similarly, if your JavaScript is doing fairly low-level wire protocol operations (sending packets of data through XmlHttpRequest), differences between the VM virtual network stack and actual network card hardware and drivers could cause changes in packet arrival timing, dropped packets, or perhaps even out of order packets.
The best course of action IMO is to do most of your testing, perhaps even all of your automated testing, in VMs simply because it's more manageable and more economical to do it that way, but also budget and schedule to do some testing on widely disparate hardware - both super fast and super awful video cards, built-in mobo audio as well as aftermarket audio cards, uniproc and multiproc systems, etc.