呃~~招免费测试的哈,嘿嘿
来源:互联网 发布:mac用什么免费杀毒软件 编辑:程序博客网 时间:2024/05/01 02:04
function assert(c, msg) {
if(!c) {
throw new Error(msg);
}
}
Object.prototype.equals = function(obj) {
return this == obj;
};
Object.prototype.compareTo = function(obj) {
return this < obj ? -1 : this == obj ? 0 : 1;
};
Number.prototype.doubleValue = function() {
return this.valueOf();
};
Number.prototype.intValue = function() {
var v = this.doubleValue();
return v < 0 ? Math.ceil(v) : v > 0 ? Math.floor(v) : 0;
};
Number.prototype.compareTo = function(obj) {
assert(obj instanceof Number, "param type is error!");
var v = obj.valueOf();
return this.valueOf() < v ? -1 : this.valueOf() > v ? 1 : 0;
};
Number.prototype.equals = function(obj) {
return this.compareTo(obj) == 0;
};
function Integer(value) {
Number.call(this, parseInt(value));
}
Integer.prototype = new Number();
Integer.prototype.toXxxString = function(obj, r) {
try {
obj = new Integer(obj);
} catch(error) {
throw error;
}
switch(arguments.length) {
case 0: return this.toString(r);
case 1: return obj.tostring(r)
}
};
Integer.prototype.toHexString = function(obj) {
return this.toXxxString(obj, 16);
};
Integer.prototype.toOctalString = function(obj) {
return this.toXxxString(obj, 8);
};
Integer.prototype.toBinaryString = function(obj) {
return this.toXxxString(obj, 2);
};
Boolean.prototype.booleanValue = function() {
return this.valueOf();
};
Boolean.prototype.equals = function(obj) {
obj = Boolean(obj);
return this.valueOf() && obj.valueOf() || !this.valueOf() && !obj.valueOf();
};
Boolean.prototype.compareTo = function(obj) {
try {
obj = Number(obj);
} catch(error) {
throw error;
}
var t = Number(this);
return t < obj ? -1 : t == obj ? 0 : 1;
};
Boolean.prototype.xor = function(b) {
b = Boolean(b);
var tmp = this.valueOf();
return tmp && !b || !tmp && b;
};
Boolean.prototype.imp = function(b) {
return !this.xor(b);
};
Boolean.prototype.notor = function(b) { // P -> Q = !P || Q
b = Boolean(b);
var tmp = this.valueOf();
return !tmp || b;
};
String.prototype.codePointAt = function(index) {
assert(index instanceof Number, "param type is error!");
return this.charCodeAt(index);
};
String.prototype.compareTo = function(str) {
assert(str instanceof String, "param type is error!");
var index = 0;
var v1 = null, v2 = null;
while(index < this.length && index < str.length) {
v1 = this.charAt(index);
v2 = str.charAt(index);
if(v1 != v2) {
return v1 > v2 ? 1 : -1;
}
index++;
}
return this.length == str.length ? 0 : index >= this.length ? -1 : 1;
};
String.prototype.compareToIgnoreCase = function(str) {
assert(str instanceof String, "param type is error!");
var tmp = this.toLowerCase();
str = str.toLowerCase();
return tmp.compareTo(str);
};
String.prototype.equals = function(str) {
return this.compareTo(str) == 0;
};
String.prototype.equalsIgnoreCase = function(str) {
assert(str instanceof String, "param type is error!");
var tmp = this.toLowerCase();
str = str.toLocaleString();
return tmp.equals(str);
};
String.prototype.toCharArray = function() {
return this.split("");
};
String.prototype.isEmpyt = function() {
return this.length == 0;
};
String.prototype.startsWith = function(str, start) {
return this.index(str, start) >= 0;
};
String.prototype.endsWith = function(str, start) {
return this.lastIndexOf(str, start) >= 0;
};
Date.prototype.compareTo = function(date) {
if(!(date instanceof Date)) {
try {
date = new Date(Date.parse(date.toString()));
} catch(error) {
throw error;
}
}
var t1 = this.getTime(), t2 = date.getTime();
return t1 > t2 ? 1 : t1 == t2 ? 0 : -1;
};
Date.prototype.equals = function(date) {
return this.compareTo(date) == 0;
};
Date.prototype.before = function(date) {
return this.compareTo(date) < 0;
};
Date.prototype.after = function(date) {
return this.compareTo(date) > 0;
};
Array.prototype.compareTo = function(arr) {
assert(arr instanceof Array, "param type is error!");
var index = 0;
while(index < this.length && index < arr.length) {
if(this[index].compareTo(arr[index]) > 0) {
return 1;
} else if(this[index].compareTo(arr[index]) < 0) {
return -1;
}
index++;
}
var max = Math.max(this.length, arr.length);
return index >= max ? 0 : index >= this.length && index < max ? -1 : 1;
};
Array.prototype.equals = function(arr) {
return this.compareTo(arr) == 0;
};
- 呃~~招免费测试的哈,嘿嘿
- 呃,继续招免费测试,模拟Java的StringBuilder类
- 贴个俺的成果,嘿嘿
- 新来的~~嘿嘿~
- 摘来的 嘿嘿
- 转载的嘿嘿!
- 来波大的 嘿嘿
- 外企招人的性格测试------------------强烈推荐
- 外企招人的性格测试
- 外企招人的性格测试题
- 谈谈“我是怎么招测试员的”
- 谈谈“我是怎么招测试员的”
- 转载了哈,嘿嘿
- 嘿嘿
- 嘿嘿
- 嘿嘿
- 嘿嘿
- 嘿嘿
- 深入浅出Liferay Portal (4)
- 形参长度可变化的方法
- 面向对象思想
- 基于角色的权限管理(转)
- 学习
- 呃~~招免费测试的哈,嘿嘿
- JVM加载class文件的原理机制
- 深入浅出Liferay Portal (5)
- 常用CSS缩写语法总结
- 呃,继续招免费测试,模拟Java的StringBuilder类
- 妙招学编程----巧用网络
- 深入浅出Liferay Portal (6
- 适可而止莫贪图
- getch() getche()getchar()