const uri = "https://www.example.com/?x=サンプル値";
const encoded = encodeURI(uri);

console.log(encoded);
// 出力: "https://www.example.com/?x=%E3%82%B5%E3%83%B3%E3%83%97%E3%83%AB%E5%80%A4"

const decoded = decodeURI(encoded);

console.log(decoded);
// 出力: "https://www.example.com/?x=サンプル値"
decodeURI(encodedURI)
const encodedURI = "https://www.example.com/%E3%83%A1%E3%83%BC%E3%83%AB"; // エンコードされたURI
const decodedString = decodeURI(encodedURI); // デコードされた文字列

console.log(decodedString); // 出力: "https://www.example.com/メール"
const uriComponent = "https://www.example.com/search?q=JavaScript & Web Development";
const encodedUriComponent = encodeURIComponent(uriComponent);

console.log(encodedUriComponent);
// 出力: "https%3A%2F%2Fwww.example.com%2Fsearch%3Fq%3DJavaScript%20%26%20Web%20Development"

const decodedUri = decodeURI(encodedUriComponent);

console.log(decodedUri);
// 出力: "https%3A%2F%2Fwww.example.com%2Fsearch%3Fq%3DJavaScript%20%26%20Web%20Development"
const uriComponent = "https://www.example.com/search?q=JavaScript & Web Development";
const encodedUriComponent = encodeURIComponent(uriComponent);
console.log(encodedUriComponent);
// 出力: "https%3A%2F%2Fwww.example.com%2Fsearch%3Fq%3DJavaScript%20%26%20Web%20Development"

const decodedUri = decodeURIComponent(encodedUriComponent);
console.log(decodedUri);
// 出力: "https://www.example.com/search?q=JavaScript & Web Development"