encodeURIComponent(string)
Last updated
Last updated
// Define a string with special characters
urlString = "Hello World! How are you?"
// Use encodeURIComponent to encode the URL component
encodedString = encodeURIComponent(urlString)
// Log the result to the console
log encodedString
// Output: Hello%20World!%20How%20are%20you%