javaScript Enumerable snippet