Name spacing

by patelsan

CoffeeScript

namespace = (name) ->
  window[name] = window[name] or {}

namespace 'util'

util.typeOf = (instance) ->
  s = typeof instance
  if s == "object"
    if instance != null
      if Object.prototype.toString.call(instance) == '[object Array]'
        s = 'array';
    else
      s = 'null'
      
console.log util.typeOf []