先決條件:JavaScript | escape()
JavaScript中的unescape()函數將字符串作為參數,並用於解碼由escape()函數編碼的字符串。通過unescape()解碼時,字符串中的十六進製序列將替換為它們所代表的字符。
用法:
unescape(string)
<script>
// Special character encoded with
// escape function
var str = escape("Geeks for Geeks!!!");
document.write("Encoded:" + str);
// New Line
document.write("<br>");
// unescape() function
document.write("Decoded:" + unescape(str))
// New Line
document.write("<br><br>");
// The exception
// @ and . not encoded.
str = escape("To contribute articles contact us" +
"at contribute@geeksforgeeks.org")
document.write("Encoded:" + str);
// New Line
document.write("<br>");
// unescape() function
document.write("Decoded:" + unescape(str))
</script>
輸出:
Encoded:Geeks%20for%20Geeks%21%21%21 Decoded:Geeks for Geeks!!! Encoded:To%20contribute%20articles%20contact%20us%20at%20contribute@geeksforgeeks.org Decoded:To contribute articles contact us at contribute@geeksforgeeks.org
相關用法
- Javascript typedArray.map()用法及代碼示例
- Javascript uneval()用法及代碼示例
- Javascript parseInt()用法及代碼示例
- Javascript addEventListener()用法及代碼示例
- Javascript console.log()用法及代碼示例
- Javascript getPrototypeOf()用法及代碼示例
- Javascript typedArray.from()用法及代碼示例
- Javascript typedArray.of()用法及代碼示例
- Javascript parseFloat()用法及代碼示例
- Javascript weakSet.has()用法及代碼示例
- Javascript weakSet.add()用法及代碼示例
- Javascript weakMap.set()用法及代碼示例
注:本文由純淨天空篩選整理自ShivamKD大神的英文原創作品 JavaScript | unescape() with examples。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。