When are you supposed to use escape instead of encodeURI / encodeURIComponent?

前端 未结 15 1153
栀梦
栀梦 2020-11-21 07:39

When encoding a query string to be sent to a web server - when do you use escape() and when do you use encodeURI() or encodeURIComponent()

15条回答
  •  情话喂你
    2020-11-21 08:07

    Also remember that they all encode different sets of characters, and select the one you need appropriately. encodeURI() encodes fewer characters than encodeURIComponent(), which encodes fewer (and also different, to dannyp's point) characters than escape().

提交回复
热议问题