What's the difference between window.location.assign(url)
and window.open(url, '_self')
?
Related questions:
What's the difference between window.location.assign(url)
and window.open(url, '_self')
?
Related questions:
Functionally? Not much. They do similar things in different ways.
Personally, I'd probably choose window.location over window.open. Even though they do the same things, using window.location for changing the current window is more common, and doesn't require knowing about '_self', which isn't used that often. My experience is my coworkers expect window.open to involve opening a window versus reusing the same one.
window.location.assign
will assign the current window a new URL value. window.open
will open a new window (which may be in a new tab, or not, depending) with the value of the url passed.
It's the difference between creating a new window and editing an existing window.