Private methods in JavaScript using prototype chaining