Netflix interview question

Enhance the contains function to make it part of the JavaScript system (e.g. HTMLElement.prototype).

Interview Answer

Anonymous

14 Mar 2012

HTMLElement.prototype.contains = function contains(b) { while ((this != b) && (b != null)) { b = b.getParent(); } return (this == b); }