I want to write a query parsing method that would belong to the location class, but am not having any luck with
window.location.prototype
or
window.prototype
My goal is to do something along the lines of:
window.location.prototype.parseQuery = function(key){
//run a test on this.search to see if it contains key and return the val
}
Is window immutable? or am I just not referencing it correctly?
TIA
You don’t need the prototype when the object already exists and there’s only one of them. You can just add a method directly to the object.
or
Also, the
windowobject is the global object in a browser so any global function is already a method on thewindowobject.