Skip to main content
14 events
when toggle format what by license comment
Dec 13, 2022 at 0:58 history edited Peter Mortensen CC BY-SA 4.0
Removed historical information (that is what the revision history is for)—the answer should be as if it was written right now.
Jul 12, 2020 at 18:10 comment added Erdal G. This is the trashiest answer I ever saw on SO haha. Why not delete it? Almost everything has been crossed out
Jul 31, 2017 at 12:26 history edited robinCTS CC BY-SA 3.0
Strikeout incorrect text
Jan 12, 2017 at 2:36 comment added Max Heiber As far as I can tell, this stuff about default properties is incorrect and there is no such thing in JS. I'll undo my downvote if someone can link to some documentation for how to override = in JS.
Oct 25, 2016 at 23:03 comment added Kevin Fegan window.location.href = url is stronger/smarter/bigger... =)
Sep 12, 2016 at 19:38 comment added Stijn de Witt "location.href = url is technically more correct" No, it isn't. As most it's more like the rest of Javascript. But in fact Location is a well-defined object and the specs around it are clear and implemented consistently across the board. So location = url is equally correct. But shorter. And thus should, imho, be preferred in our perpetual quest to shave as much overhead off of our pages as possible.
Mar 8, 2016 at 16:42 comment added Sai Dubbaka Down voting for the same reason as given by @bobince
Apr 24, 2015 at 9:39 comment added JustAMartin location.href = url is technically more correct and thus more safe (or fool-proof). In general, when you assign myObject.someProp = someThing you do not expect that the value of someThing will be assigned to myObject.someProp.someInnerProp, right? Then why would you expect it from location.href? It seems to be even dangerous to rely upon such behavior and assume that it will always work that quirky way.
Nov 18, 2014 at 22:47 history edited Timo Tijhof CC BY-SA 3.0
formatting
Jun 18, 2014 at 0:53 comment added fregante location = url is cuter
Feb 18, 2014 at 1:58 comment added Eric window.location = url is prettier
Nov 12, 2012 at 22:36 comment added bobince This sounds good but isn't really true. There is no concept of a default property in the DOM or JavaScript in general. Assigning a string to location works because the property was defined to have this special assignment behaviour back in JavaScript 1.0 and every browser since has implemented that. HTML5 now requires it. So whilst it may be prettier or more consistent to assign to .href, there is no backward or forward compatibility advantage to doing so.
May 18, 2012 at 20:38 comment added six5536 Good explanation, better than just general comments about readability or maintenance. In reality in this particular case the object model will not be changed, as half the web would halt - therefore use either... it doesn't matter which
Apr 4, 2012 at 17:15 history answered Kirby L. Wallace CC BY-SA 3.0