extend and clone functionality for nodejs and the browser