w3schools says the following about encodeURIComponent function:
This function encodes special characters. In addition,
it encodes the following characters:, / ? : @ & = + $ #.
Does that mean that it cannot encode a backslash (\)?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
This definition is vague as to what “special characters” are. It sounds like a comparison between
encodeURIandencodeURIComponent. Both will correctly escape\as%5C, so you don’t have to worry about backslashes.encodeURIwill leave the listed characters as it is assumed that the entire URI is being encoded:encodeURIComponentwill escape everything as it is assumed that the string is to be used as part of a query-string: