Javascript - Global decodeURIComponent() Function

The decodeURIComponent() function decodes a URI component.

Description

The decodeURIComponent() function decodes a URI component.

Syntax

decodeURIComponent(uri)

Parameter Values

Parameter Require Description
uri Required. The URI to be decoded

Return

A String, representing the decoded URI

Example

Decode a URI after encoding it:

Demo

//decode a URI after encoding it.
var uri = "https://book2s.com/my test.asp?name=stale&lang=java";
var uri_enc = encodeURIComponent(uri);
var uri_dec = decodeURIComponent(uri_enc);
var res = "Encoded URI: " + uri_enc + "\n" + "Decoded URI: " + uri_dec;
console.log(res);/*  ww w  .  j  a v a  2 s  . c  o m*/

Result