[removed] Setting location.href versus location

后端 未结 7 1793
野性不改
野性不改 2020-11-22 17:16

When would you set location to a URL string versus setting location.href?

location = \"http://www.stackoverflow.com\";
7条回答
  •  甜味超标
    2020-11-22 17:53

    Even if both work, I would use the latter. location is an object, and assigning a string to an object doesn't bode well for readability or maintenance.

提交回复
热议问题