Difference between escape(), encodeURI(), encodeURIComponent()

前端 未结 5 1357
走了就别回头了
走了就别回头了 2021-01-30 00:32

In JavaScript, what is the difference between these?

  1. escape() / unescape()
  2. encodeuri() / decodeuri()
5条回答
  •  逝去的感伤
    2021-01-30 00:48

    • escape — broken, deprecated, do not use
    • encodeURI — encodes characters that are not allowed (raw) in URLs (use it to fix up broken URIs if you can't fix them beforehand)
    • encodeURIComponent — as encodeURI plus characters with special meaning in URIs (use it to encode data for inserting into a URI)

提交回复
热议问题