But I am not able justify/understand whether I should use escape to encode strings or should I use encodeurlcomponent. I tried reading some online blogs but not understood yet.
Any pointers to which one should be used under what circumstances.
escape()
will not encode: @*/+
encodeURI()
will not encode: ~!@#$&*()=:/,;?+'
encodeURIComponent()
will not encode: ~!*()'
For more information, have a look at these questions:
Encode URL in JavaScript?
When are you supposed to use escape instead of encodeURI / encodeURIComponent?
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With