I often see window.location.hash
and location.hash
(hash here being a sample) referenced in various Javascripts. What is the difference between those calls (that seem to me have identical results).
Asked
Active
Viewed 1,371 times
0

Patrick
- 691
- 8
- 30
-
check this one - its the same question (here)[http://stackoverflow.com/questions/4709037/window-location-versus-just-location] – Mike B Mar 19 '17 at 13:07
1 Answers
2
window
is the global object in the browser, so unqualified, undeclared names are looked up on it by default. As such, window.location
and location
mean the exact same thing unless a scoped variable named location
has been declared.

ShadowRanger
- 143,180
- 12
- 188
- 271
-
@Kinduser: Eh. I answered before any duplicates were linked. No point in deleting when it's not wrong/misleading. – ShadowRanger Mar 19 '17 at 13:16
-
It's not misleading/wrong, I agree, but moderators are deleting questions/answers for even more trivial reasons nowadays... – kind user Mar 19 '17 at 13:22