What does Javascript take as default?

Asked

Viewed 42 times

0

Example, I have the window.location.href, the location.href, the document.location.href

This second in the case, what will Javascript leave as default? Window? Default I say, I can use both the window and Document, so since I don’t put anything, it takes which one? Or is there difference of the 3 commands?

  • Related: https://answall.com/q/179468/101

1 answer

2

window.location is an object containing all information about the current document Location (host, href, ports, protocols, etc.)

document.location is a synonym for window.location, but it’s been deprecated for a long time. Don’t use this.

location.href is the abbreviated form of window.location.href (if you call global object location - window, so this is window.location.href), and in the end this is just a string with the full url of the website.

Sources

  • 1

    You can cite the sources that base your assertions?

  • It’s a little ambiguous which should no longer be used.

  • Edits made with font and taking ambiguity

Browser other questions tagged

You are not signed in. Login or sign up in order to post.