function dom(n) {
      if (typeof n === 'string') n = document.createElement(n);
      for (var a, i = 1; i < arguments.length; i++) {
        if (!(a = arguments[i])) continue;
        if (typeof a !== 'object') a = document.createTextNode(a);
        if (a.nodeType) n.appendChild(a);
        else for (var key in a) {
          if (!Object.prototype.hasOwnProperty.call(a, key)) continue;
          if (key[0] === '$') n.style[key.slice(1)] = a[key];
          else n.setAttribute(key, a[key]);
        }
      }
      return n;
    }
dom - Document Object Manipulator
Usage:
  dom('<tag>'|<node>[, ...{<attributes>|<$styles>}|<child-node>|'<text>'])
Examples:
  dom('div', {id:'xyz'}, dom('p', 'CM rocks!', {$color:'red'}))
  dom(document.head, dom('script', 'alert("hello!")'))
Not supported:
  dom('p', ['arrays are objects'], Error('objects specify attributes'))