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%2Fp.rizon.top%3A443%2Fhttps%2Fjsnuggets.com%3Ftodays%20%23post
decodeURIComponent()
To decode the URI encoded by
encodeURIComponent().
const url =
'https%3A%2F%2Fp.rizon.top%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)

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

More from Ideas2IT Technologies (20)

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

Recently uploaded (20)

Making significant Software Architecture decisions
Making significant Software Architecture decisions
Bert Jan Schrijver
 
GDG Douglas - Google AI Agents: Your Next Intern?
GDG Douglas - Google AI Agents: Your Next Intern?
felipeceotto
 
Looking for a BIRT Report Alternative Here’s Why Helical Insight Stands Out.pdf
Looking for a BIRT Report Alternative Here’s Why Helical Insight Stands Out.pdf
Varsha Nayak
 
Step by step guide to install Flutter and Dart
Step by step guide to install Flutter and Dart
S Pranav (Deepu)
 
UPDASP a project coordination unit ......
UPDASP a project coordination unit ......
withrj1
 
Software Testing & it’s types (DevOps)
Software Testing & it’s types (DevOps)
S Pranav (Deepu)
 
What is data visualization and how data visualization tool can help.pdf
What is data visualization and how data visualization tool can help.pdf
Varsha Nayak
 
IBM Rational Unified Process For Software Engineering - Introduction
IBM Rational Unified Process For Software Engineering - Introduction
Gaurav Sharma
 
Who will create the languages of the future?
Who will create the languages of the future?
Jordi Cabot
 
Porting Qt 5 QML Modules to Qt 6 Webinar
Porting Qt 5 QML Modules to Qt 6 Webinar
ICS
 
How Insurance Policy Management Software Streamlines Operations
How Insurance Policy Management Software Streamlines Operations
Insurance Tech Services
 
SAP PM Module Level-IV Training Complete.ppt
SAP PM Module Level-IV Training Complete.ppt
MuhammadShaheryar36
 
Milwaukee Marketo User Group June 2025 - Optimize and Enhance Efficiency - Sm...
Milwaukee Marketo User Group June 2025 - Optimize and Enhance Efficiency - Sm...
BradBedford3
 
Async-ronizing Success at Wix - Patterns for Seamless Microservices - Devoxx ...
Async-ronizing Success at Wix - Patterns for Seamless Microservices - Devoxx ...
Natan Silnitsky
 
Shell Skill Tree - LabEx Certification (LabEx)
Shell Skill Tree - LabEx Certification (LabEx)
VICTOR MAESTRE RAMIREZ
 
Migrating to Azure Cosmos DB the Right Way
Migrating to Azure Cosmos DB the Right Way
Alexander (Alex) Komyagin
 
Integrating Survey123 and R&H Data Using FME
Integrating Survey123 and R&H Data Using FME
Safe Software
 
wAIred_RabobankIgniteSession_12062025.pptx
wAIred_RabobankIgniteSession_12062025.pptx
SimonedeGijt
 
Advanced Token Development - Decentralized Innovation
Advanced Token Development - Decentralized Innovation
arohisinghas720
 
IMAGE CLASSIFICATION USING CONVOLUTIONAL NEURAL NETWORK.P.pptx
IMAGE CLASSIFICATION USING CONVOLUTIONAL NEURAL NETWORK.P.pptx
usmanch7829
 
Making significant Software Architecture decisions
Making significant Software Architecture decisions
Bert Jan Schrijver
 
GDG Douglas - Google AI Agents: Your Next Intern?
GDG Douglas - Google AI Agents: Your Next Intern?
felipeceotto
 
Looking for a BIRT Report Alternative Here’s Why Helical Insight Stands Out.pdf
Looking for a BIRT Report Alternative Here’s Why Helical Insight Stands Out.pdf
Varsha Nayak
 
Step by step guide to install Flutter and Dart
Step by step guide to install Flutter and Dart
S Pranav (Deepu)
 
UPDASP a project coordination unit ......
UPDASP a project coordination unit ......
withrj1
 
Software Testing & it’s types (DevOps)
Software Testing & it’s types (DevOps)
S Pranav (Deepu)
 
What is data visualization and how data visualization tool can help.pdf
What is data visualization and how data visualization tool can help.pdf
Varsha Nayak
 
IBM Rational Unified Process For Software Engineering - Introduction
IBM Rational Unified Process For Software Engineering - Introduction
Gaurav Sharma
 
Who will create the languages of the future?
Who will create the languages of the future?
Jordi Cabot
 
Porting Qt 5 QML Modules to Qt 6 Webinar
Porting Qt 5 QML Modules to Qt 6 Webinar
ICS
 
How Insurance Policy Management Software Streamlines Operations
How Insurance Policy Management Software Streamlines Operations
Insurance Tech Services
 
SAP PM Module Level-IV Training Complete.ppt
SAP PM Module Level-IV Training Complete.ppt
MuhammadShaheryar36
 
Milwaukee Marketo User Group June 2025 - Optimize and Enhance Efficiency - Sm...
Milwaukee Marketo User Group June 2025 - Optimize and Enhance Efficiency - Sm...
BradBedford3
 
Async-ronizing Success at Wix - Patterns for Seamless Microservices - Devoxx ...
Async-ronizing Success at Wix - Patterns for Seamless Microservices - Devoxx ...
Natan Silnitsky
 
Shell Skill Tree - LabEx Certification (LabEx)
Shell Skill Tree - LabEx Certification (LabEx)
VICTOR MAESTRE RAMIREZ
 
Integrating Survey123 and R&H Data Using FME
Integrating Survey123 and R&H Data Using FME
Safe Software
 
wAIred_RabobankIgniteSession_12062025.pptx
wAIred_RabobankIgniteSession_12062025.pptx
SimonedeGijt
 
Advanced Token Development - Decentralized Innovation
Advanced Token Development - Decentralized Innovation
arohisinghas720
 
IMAGE CLASSIFICATION USING CONVOLUTIONAL NEURAL NETWORK.P.pptx
IMAGE CLASSIFICATION USING CONVOLUTIONAL NEURAL NETWORK.P.pptx
usmanch7829
 
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%2Fp.rizon.top%3A443%2Fhttps%2Fjsnuggets.com%3Ftodays%20%23post decodeURIComponent() To decode the URI encoded by encodeURIComponent(). const url = 'https%3A%2F%2Fp.rizon.top%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); // 😉