JavaScript参考手册
全球对象 | Global Objects
escape
废弃的 escape()
方法生成新的由十六进制转义序列替换的字符串. 使用encodeURI
或encodeURIComponent
代替.
语法
escape(str)
参数
str
待编码的字符串.
返回值
一个新字符串,其中某些字符已经被转义。
描述
escape
函数是全局对象的属性. 特色字符如: @*_+-./ 被排除在外.
字符的16进制格式值,当该值小于等于0xFF时,用一个2位转移序列: %xx 表示. 大于的话则使用4位序列:%uxxxx 表示.
示例
escape('abc123'); // "abc123"
escape('äöü'); // "%E4%F6%FC"
escape('ć'); // "%u0107"
// special characters
escape('@*_+-./'); // "@*_+-./"
规范
Specification |
Status |
Comment |
---|---|---|
ECMAScript 1st Edition (ECMA-262) |
Standard |
Initial definition. |
ECMAScript 5.1 (ECMA-262)The definition of 'escape' in that specification. |
Standard |
Defined in the (informative) Compatibility Annex B |
ECMAScript 2015 (6th Edition, ECMA-262)The definition of 'escape' in that specification. |
Standard |
Defined in the (normative) Annex B for Additional ECMAScript Features for Web Browsers |
ECMAScript Latest Draft (ECMA-262)The definition of 'escape' in that specification. |
Living Standard |
Defined in the (normative) Annex B for Additional ECMAScript Features for Web Browsers |
浏览器兼容性
Feature |
Chrome |
Edge |
Firefox (Gecko) |
Internet Explorer |
Opera |
Safari |
---|---|---|---|---|---|---|
Basic support |
(Yes) |
(Yes) |
(Yes) |
(Yes) |
(Yes) |
(Yes) |
Feature |
Android |
Chrome for Android |
Edge |
Firefox Mobile (Gecko) |
IE Mobile |
Opera Mobile |
Safari Mobile |
---|---|---|---|---|---|---|---|
Basic support |
(Yes) |
(Yes) |
(Yes) |
(Yes) |
(Yes) |
(Yes) |
(Yes) |
全球对象 | Global Objects相关
JavaScript 是一种高级编程语言,通过解释执行,是一门动态类型,面向对象(基于原型)的解释型语言。它已经由ECMA(欧洲电脑制造商协会)通过 ECMAScript 实现语言的标准化。它被世界上的绝大多数网站所使用,也被世界主流浏览器( Chrome、IE、FireFox、Safari、Opera )支持。JavaScript 是一门基于原型、函数先行的语言,是一门多范式的语言,它支持面向对象编程,命令式编程,以及函数式编程。它提供语法来操控文本、数组、日期以及正则表达式等,不支持 I/O,比如网络