location.href property vs. location.assign() method

后端 未结 5 2027
名媛妹妹
名媛妹妹 2020-12-05 09:17

Is there any particular advantage/disadvantage in JavaScript memory consumption between using location.href = url as opposed to location.assign(url)

5条回答
  •  青春惊慌失措
    2020-12-05 10:05

    I always used and never had problems with:

    location.href = url;
    

    Calling a function should be slightly slower than accessing the property, but in terms of memory there should not be a big difference in my humble opinion.

提交回复
热议问题