您的位置:首页 > Web前端 > JavaScript

js 灵活写法

2016-07-13 14:55 513 查看
$(document).ready(initPage);
function initPage() {
alert((8).double1.square);//256
//也可以这样写
alert(8["double1"]["square"])
// 256
}

Number.prototype = Object.defineProperty(
Number.prototype, "double1", {
get: function (){return (this + this)}
}
);

Number.prototype =  Object.defineProperty(
Number.prototype, "square", {
get: function (){return (this * this)}
}
);
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  js 灵活写法