Some quick comments: These lines seem mis-indented, and perhaps you should add a comment why there is a `.hasOwnProperty('length')` check?