encodeURIComponent() ফাংশনটি একটি URI কম্পোনেন্ট গ্রহণ করে এবং সেটিকে এনকোড করে, URI-রিজার্ভড ক্যারেক্টারসহ সব স্পেশাল ক্যারেক্টার এনকোড করে।
সিনট্যাক্স
encodeURIComponent(uriComponent)
উদাহরণ
<html> <head> <title>JavaScript Example</title> </head> <body> <script type="text/javascript"> document.write(encodeURIComponent('https://www.example.com/')); document.write("<br>"); var encoded = encodeURIComponent('https://www.tutorialspoint.com/'); document.write(encodeURIComponent(encoded)); // double encoding </script> </body> </html>
আউটপুট
http%3A%2F%2Fwww.example.com%2F http%253A%252F%252Fwww.tutorialspoint.com%252F