Switch Object.is(Array|String|Number) to use the vastly-superior approach discovered by Juriy.
This commit is contained in:
parent
31d1c6fd48
commit
997689fcea
@ -1,4 +1,6 @@
|
||||
* Further fix to ensure Object#is(String|Number) do not throw exceptions on host objects in IE. (grepmaster, kangax, Tobie Langel, Andrew Dupont)
|
||||
* Switch Object.is(Array|String|Number) to use the vastly-superior approach discovered by Juriy. (kangax)
|
||||
|
||||
* Further fix to ensure Object.is(String|Number) do not throw exceptions on host objects in IE. (grepmaster, kangax, Tobie Langel, Andrew Dupont)
|
||||
|
||||
* Ensure Enumerable#grep can handle strings with RegExp metacharacters. (Marton Kiss-Albert, kangax)
|
||||
|
||||
|
@ -1,4 +1,10 @@
|
||||
(function() {
|
||||
|
||||
function getClass(object) {
|
||||
return Object.prototype.toString.call(object)
|
||||
.match(/^\[object\s(.*)\]$/)[1];
|
||||
}
|
||||
|
||||
function extend(destination, source) {
|
||||
for (var property in source)
|
||||
destination[property] = source[property];
|
||||
@ -70,8 +76,7 @@
|
||||
}
|
||||
|
||||
function isArray(object) {
|
||||
return object != null && typeof object === "object" &&
|
||||
'splice' in object && 'join' in object;
|
||||
return getClass(object) === "Array";
|
||||
}
|
||||
|
||||
function isHash(object) {
|
||||
@ -83,19 +88,11 @@
|
||||
}
|
||||
|
||||
function isString(object) {
|
||||
try {
|
||||
return typeof (object && object.valueOf()) === "string";
|
||||
} catch(e) {
|
||||
return false;
|
||||
}
|
||||
return getClass(object) === "String";
|
||||
}
|
||||
|
||||
function isNumber(object) {
|
||||
try {
|
||||
return typeof (object && object.valueOf()) === "number";
|
||||
} catch(e) {
|
||||
return false;
|
||||
}
|
||||
return getClass(object) === "Number";
|
||||
}
|
||||
|
||||
function isUndefined(object) {
|
||||
|
Loading…
Reference in New Issue
Block a user