Skip to content

Instantly share code, notes, and snippets.

@jixunmoe jixunmoe/Chinese.js
Last active Aug 29, 2015

Embed
What would you like to do?
Chinese JavaScript
var 中文 = (function () {
var _ = window;
_. = true;
_. = false;
[{
: document,
中文: '文档',
映射: {
createTextNode: '创建文本节点',
createElement: '创建元素',
body: '页面'
},
目标为类: false
}, {
: Array,
中文: '数组',
映射: {
push: '加入'
},
目标为类: true
}, {
: Element,
中文: '元素',
映射: {
appendChild: '插入元素'
},
目标为类: true
}].map (function (枚举项) {
if (!_[枚举项.中文]) _[枚举项.中文] = {};
for (var 映射项 in 枚举项.映射)
if (枚举项.映射.hasOwnProperty(映射项))
if (枚举项.目标为类)
枚举项..prototype[枚举项.映射[映射项]] = 枚举项..prototype[映射项];
else
_[枚举项.中文][枚举项.映射[映射项]] = 枚举项.[映射项].bind ? 枚举项.[映射项].bind(枚举项.) : 枚举项.[映射项];
});
return _;
})();
文档.页面.插入元素 (文档.创建文本节点('用中文写代码 2333'));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.