SlideShare a Scribd company logo
JS NUGGETS
encodeURI()
Used to encode a URI by replacing URL
reserved characters with their UTF-8 encoding.
const url = 'https://jsnuggets.com?todays #post';
encodeURI(url);
// "https://jsnuggets.com?todays%20#post"
decodeURI()
Used to decode the URI encoded by
encodeURI().
const url = 'https://jsnuggets.com?todays%20#post';
decodeURI(url);
// 'https://jsnuggets.com?todays #post';
encodeURIComponent()
encodeURIComponent is designed to encode
everything, where encodeURI ignores a URL's
domain related roots. In addition, it encodes
the following characters as well: , / ? : @ & =
+ $ #
const url = 'https://jsnuggets.com?todays #post';
encodeURIComponent(url);
// https%3A%2F%2Fblue-sea-697d.quartiers047.workers.dev%3A443%2Fhttps%2Fjsnuggets.com%3Ftodays%20%23post
decodeURIComponent()
To decode the URI encoded by
encodeURIComponent().
const url =
'https%3A%2F%2Fblue-sea-697d.quartiers047.workers.dev%3A443%2Fhttps%2Fjsnuggets.com%3Ftodays%20%23post';
decodeURIComponent(url);
// https://jsnuggets.com?todays #post
Works effectively on browser console too!!
const emoji = encodeURI('😉');
// %F0%9F%98%89
decodeURI(emoji);
// 😉

More Related Content

What's hot (11)

ODP
Embedding perl
Marian Marinov
 
PDF
Phantomjs Screenshot Server on Heroku
Shinichi Tomita
 
PDF
Integração contínua com Hudson CI
Almir Mendes
 
PDF
CGI.pm - 3ло?!
Anatoly Sharifulin
 
PPTX
Token based-oauth2
andreyradzkov
 
PDF
Beyond Golden Containers: Complementing Docker with Puppet
lutter
 
PPT
الجيل الثاني من شبكات المعلومات
abedelaziz benzine
 
TXT
新建 文本文档
mytwice
 
PPTX
Secure Payments Over Mixed Communication Media
Jonathan LeBlanc
 
PDF
SSH I/O Streaming via Redis-based Persistent Message Queue -Mani Tadayon
Redis Labs
 
PDF
Implementing JMS Integration Solutions with WSO2 ESB
WSO2
 
Embedding perl
Marian Marinov
 
Phantomjs Screenshot Server on Heroku
Shinichi Tomita
 
Integração contínua com Hudson CI
Almir Mendes
 
CGI.pm - 3ло?!
Anatoly Sharifulin
 
Token based-oauth2
andreyradzkov
 
Beyond Golden Containers: Complementing Docker with Puppet
lutter
 
الجيل الثاني من شبكات المعلومات
abedelaziz benzine
 
新建 文本文档
mytwice
 
Secure Payments Over Mixed Communication Media
Jonathan LeBlanc
 
SSH I/O Streaming via Redis-based Persistent Message Queue -Mani Tadayon
Redis Labs
 
Implementing JMS Integration Solutions with WSO2 ESB
WSO2
 

More from Ideas2IT Technologies (20)

PDF
Version comaparison in JavaScript
Ideas2IT Technologies
 
PDF
Currying in JavaScript
Ideas2IT Technologies
 
PDF
JS Testing Frameworks
Ideas2IT Technologies
 
PDF
Iterables and Iterators in JavaScript
Ideas2IT Technologies
 
PDF
String comparison in javascript
Ideas2IT Technologies
 
PDF
JavaScript symbols
Ideas2IT Technologies
 
PDF
Json.parse() in JavaScript
Ideas2IT Technologies
 
PDF
Bubble sort in Java Script
Ideas2IT Technologies
 
PDF
Performance analysis in merging arrays - JavaScript
Ideas2IT Technologies
 
PDF
Nullish coalescing in JavaScript
Ideas2IT Technologies
 
PDF
Conditionally add keys in JavaScript
Ideas2IT Technologies
 
PDF
What is Big O in JavaScript - Part-1
Ideas2IT Technologies
 
PDF
Variable hoisting in JavaScript
Ideas2IT Technologies
 
PDF
Formidable ES6 spread operator in JavaScript
Ideas2IT Technologies
 
PDF
Logging in JavaScript - Part-5
Ideas2IT Technologies
 
PDF
Logging in JavaScript - Part-4
Ideas2IT Technologies
 
PDF
Logging in JavaScript - Part-3
Ideas2IT Technologies
 
PDF
Logging in JavaScript - part-2
Ideas2IT Technologies
 
PDF
Logging in JavaScript - part-1
Ideas2IT Technologies
 
PDF
Array vs set in JavaScript
Ideas2IT Technologies
 
Version comaparison in JavaScript
Ideas2IT Technologies
 
Currying in JavaScript
Ideas2IT Technologies
 
JS Testing Frameworks
Ideas2IT Technologies
 
Iterables and Iterators in JavaScript
Ideas2IT Technologies
 
String comparison in javascript
Ideas2IT Technologies
 
JavaScript symbols
Ideas2IT Technologies
 
Json.parse() in JavaScript
Ideas2IT Technologies
 
Bubble sort in Java Script
Ideas2IT Technologies
 
Performance analysis in merging arrays - JavaScript
Ideas2IT Technologies
 
Nullish coalescing in JavaScript
Ideas2IT Technologies
 
Conditionally add keys in JavaScript
Ideas2IT Technologies
 
What is Big O in JavaScript - Part-1
Ideas2IT Technologies
 
Variable hoisting in JavaScript
Ideas2IT Technologies
 
Formidable ES6 spread operator in JavaScript
Ideas2IT Technologies
 
Logging in JavaScript - Part-5
Ideas2IT Technologies
 
Logging in JavaScript - Part-4
Ideas2IT Technologies
 
Logging in JavaScript - Part-3
Ideas2IT Technologies
 
Logging in JavaScript - part-2
Ideas2IT Technologies
 
Logging in JavaScript - part-1
Ideas2IT Technologies
 
Array vs set in JavaScript
Ideas2IT Technologies
 
Ad

Recently uploaded (20)

PDF
Alexander Marshalov - How to use AI Assistants with your Monitoring system Q2...
VictoriaMetrics
 
PPTX
Java Native Memory Leaks: The Hidden Villain Behind JVM Performance Issues
Tier1 app
 
PDF
Digger Solo: Semantic search and maps for your local files
seanpedersen96
 
PPTX
How Cloud Computing is Reinventing Financial Services
Isla Pandora
 
PDF
Beyond Binaries: Understanding Diversity and Allyship in a Global Workplace -...
Imma Valls Bernaus
 
PPTX
Home Care Tools: Benefits, features and more
Third Rock Techkno
 
DOCX
Import Data Form Excel to Tally Services
Tally xperts
 
PDF
GetOnCRM Speeds Up Agentforce 3 Deployment for Enterprise AI Wins.pdf
GetOnCRM Solutions
 
PDF
HiHelloHR – Simplify HR Operations for Modern Workplaces
HiHelloHR
 
PPTX
Agentic Automation: Build & Deploy Your First UiPath Agent
klpathrudu
 
PDF
Linux Certificate of Completion - LabEx Certificate
VICTOR MAESTRE RAMIREZ
 
PPTX
Fundamentals_of_Microservices_Architecture.pptx
MuhammadUzair504018
 
PDF
Efficient, Automated Claims Processing Software for Insurers
Insurance Tech Services
 
PPTX
Agentic Automation Journey Session 1/5: Context Grounding and Autopilot for E...
klpathrudu
 
PDF
iTop VPN With Crack Lifetime Activation Key-CODE
utfefguu
 
PPTX
MailsDaddy Outlook OST to PST converter.pptx
abhishekdutt366
 
PDF
Powering GIS with FME and VertiGIS - Peak of Data & AI 2025
Safe Software
 
PPTX
Empowering Asian Contributions: The Rise of Regional User Groups in Open Sour...
Shane Coughlan
 
PDF
SciPy 2025 - Packaging a Scientific Python Project
Henry Schreiner
 
PPTX
ChiSquare Procedure in IBM SPSS Statistics Version 31.pptx
Version 1 Analytics
 
Alexander Marshalov - How to use AI Assistants with your Monitoring system Q2...
VictoriaMetrics
 
Java Native Memory Leaks: The Hidden Villain Behind JVM Performance Issues
Tier1 app
 
Digger Solo: Semantic search and maps for your local files
seanpedersen96
 
How Cloud Computing is Reinventing Financial Services
Isla Pandora
 
Beyond Binaries: Understanding Diversity and Allyship in a Global Workplace -...
Imma Valls Bernaus
 
Home Care Tools: Benefits, features and more
Third Rock Techkno
 
Import Data Form Excel to Tally Services
Tally xperts
 
GetOnCRM Speeds Up Agentforce 3 Deployment for Enterprise AI Wins.pdf
GetOnCRM Solutions
 
HiHelloHR – Simplify HR Operations for Modern Workplaces
HiHelloHR
 
Agentic Automation: Build & Deploy Your First UiPath Agent
klpathrudu
 
Linux Certificate of Completion - LabEx Certificate
VICTOR MAESTRE RAMIREZ
 
Fundamentals_of_Microservices_Architecture.pptx
MuhammadUzair504018
 
Efficient, Automated Claims Processing Software for Insurers
Insurance Tech Services
 
Agentic Automation Journey Session 1/5: Context Grounding and Autopilot for E...
klpathrudu
 
iTop VPN With Crack Lifetime Activation Key-CODE
utfefguu
 
MailsDaddy Outlook OST to PST converter.pptx
abhishekdutt366
 
Powering GIS with FME and VertiGIS - Peak of Data & AI 2025
Safe Software
 
Empowering Asian Contributions: The Rise of Regional User Groups in Open Sour...
Shane Coughlan
 
SciPy 2025 - Packaging a Scientific Python Project
Henry Schreiner
 
ChiSquare Procedure in IBM SPSS Statistics Version 31.pptx
Version 1 Analytics
 
Ad

Cool usage of Encoding and Decoding a URI in Javascript

  • 2. encodeURI() Used to encode a URI by replacing URL reserved characters with their UTF-8 encoding. const url = 'https://jsnuggets.com?todays #post'; encodeURI(url); // "https://jsnuggets.com?todays%20#post" decodeURI() Used to decode the URI encoded by encodeURI(). const url = 'https://jsnuggets.com?todays%20#post'; decodeURI(url); // 'https://jsnuggets.com?todays #post';
  • 3. encodeURIComponent() encodeURIComponent is designed to encode everything, where encodeURI ignores a URL's domain related roots. In addition, it encodes the following characters as well: , / ? : @ & = + $ # const url = 'https://jsnuggets.com?todays #post'; encodeURIComponent(url); // https%3A%2F%2Fblue-sea-697d.quartiers047.workers.dev%3A443%2Fhttps%2Fjsnuggets.com%3Ftodays%20%23post decodeURIComponent() To decode the URI encoded by encodeURIComponent(). const url = 'https%3A%2F%2Fblue-sea-697d.quartiers047.workers.dev%3A443%2Fhttps%2Fjsnuggets.com%3Ftodays%20%23post'; decodeURIComponent(url); // https://jsnuggets.com?todays #post
  • 4. Works effectively on browser console too!! const emoji = encodeURI('😉'); // %F0%9F%98%89 decodeURI(emoji); // 😉