let objectFactory = function(constr) {if(typeof constr !== "function") {throw "first parameter must be function"}let newObj = Object.create(constr.prototype)let arg = [].slice.call(arguments,1)let ret = constr.apply(newObj,arg)let isObject = typeof ret === "object" && ret !== nulllet isFunction = typeof ret === "function"if(isObject || isFunction) {return ret}return newObj}
