var obj = "{a:1,b:2}"; // 看起来像对象的字符串
eval("("+ obj +")") // {a: 1, b: 2}
var number = 4 (number & number -1) === 0 // true
var a = 4,b = 3 a = a ^ b // 7 b = a ^ b // 4 a = b ^ a // 3
var temp = new Date(); var regex = /\//g; (temp.toLocaleDateString() + ' ' + temp.toLocaleTimeString().slice(2)).replace(regex,'-'); // "2015-5-7 9:04:10"
new Date("2015-5-7 9:04:10");
// Thu May 07 2015 09:04:10 GMT+0800 (CST)
(new Date).valueOf(); // 1431004132641
var number = "23" typeof number // string typeof +number // number
new Date // Tue May 12 2015 22:21:33 GMT+0800 (CST) +new Date // 1431440459887
var url = encodeURIComponent('http://segmentfault.com/questions/newest')
// "http%3A%2F%2Fsegmentfault.com%2Fquestions%2Fnewest"
decodeURIComponent(url) // "http://segmentfault.com/questions/newest"
number.toFixed() // "12346" number.toFixed(3) // "12345.679" number.toFixed(6) // "12345.678900"
typeof 3 // "number" typeof "333" // "string" typeof false // "boolean"
typeof new Date() // "object"
typeof [] // "object"
typeof {} // "object"
typeof null // "object"
toString instanceof Function // true (new Date) instanceof Date // true [] instanceof Object // true [] instanceof Array // true
var toString = Object.prototype.toString; toString.call(new Date) // "[object Date]" toString.call(new Array) // "[object Array]" toString.call(new Object) // "[object Object]" toString.call(new Number) // "[object Number]" toString.call(new String) // "[object String]" toString.call(new Boolean) // "[object Boolean]"
//Shape - superclass
function Shape() {
this.x = 0;
this.y = 0;
}
Shape.prototype.move = function(x, y) {
this.x += x;
this.y += y;
console.info("Shape moved.");
};
// Rectangle - subclass
function Rectangle() {
Shape.call(this); //call super constructor.
}
Rectangle.prototype = Object.create(Shape.prototype);
var rect = new Rectangle();
rect instanceof Rectangle //true.
rect instanceof Shape //true.
rect.move(1, 1); //Outputs, "Shape moved."
机械节能产品生产企业官网模板...
大气智能家居家具装修装饰类企业通用网站模板...
礼品公司网站模板
宽屏简约大气婚纱摄影影楼模板...
蓝白WAP手机综合医院类整站源码(独立后台)...苏ICP备2024110244号-2 苏公网安备32050702011978号 增值电信业务经营许可证编号:苏B2-20251499 | Copyright 2018 - 2025 源码网商城 (www.ymwmall.com) 版权所有