If I type: window['alert']
in the console it will find the alert()
function.
However if I type: window['location.replace']
It will be undefined
. Why can't I access the location.replace
function?
replace()
is a function found in the object window.location
, or window['location']
, so you will have to write:
window.location.replace
or
window['location']['replace']
What you want is window['location']['replace']
(or window['location'].replace
).
"location.replace" is not inside of "window". Rather, "replace" is inside of "location", which is inside of "window". Thus, it must be accessed in that order.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With