<http://jsfiddle.net/sidonaldson/ZuPYM/>

```
(function() {
  if (window.DeviceOrientationEvent) 
  {
      $("e").innerHTML = "DeviceOrientationEvent";
      window.addEventListener('deviceorientation', function(e) 
      {
          // y-axis - yaw
          var g = e.gamma || 0;
          // x-axis - tilt
          var b = e.beta || 0;
          // z=axis - swivel
          var a = e.alpha || 0;
          // degree north
          var c = e.compassHeading || e.webkitCompassHeading || 0;
          // accuracy in deg
          var accuracy = e.compassAccuracy || e.webkitCompassAccuracy || 0;
          deviceOrientationHandler(g, b, a, c, accuracy);
      }, false);
  }     
  else
  {
      $("e").innerHTML = "NOT SUPPORTED #FAIL";
  }
})();

```

1. Why does the function have a format of `(function(...) {...}) ();` What is going on here I have never seen a function declared like this.
2. Is the `$` use a variable name like a `_` in other languages
3. How does this function keep on looping, in C++ you needed a while or for or recursion what is going on with the `function('e')`.