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

Published: 05 April 2024
on channel: Code Samples
52
1

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():
Use escape:
escape("% +&=");

OR
use encodeURI() / encodeURIComponent()
encodeURI("http://www.google.com?var1=value1&var2=value2");

encodeURIComponent("var1=value1&var2=value2");
B.2.1.1 escape: https://www.ecma-international.org/ec...
introduction text of Annex B: https://www.ecma-international.org/ec...
https://developer.mozilla.org/en-US/d... https://developer.mozilla.org/en-US/d...
RFC3986: https://www.rfc-editor.org/rfc/rfc398...
http://en.wikipedia.org/wiki/Percent-... http://en.wikipedia.org/wiki/Percent-...


Watch video javascript - When are you supposed to use escape instead of encodeURI / encodeURIComponent? online without registration, duration hours minute second in high quality. This video was added by user Code Samples 05 April 2024, don't forget to share it with your friends and acquaintances, it has been viewed on our site 52 once and liked it 1 people.