var lowercase = function (string) {
return isString (string) ? string.toLowerCase () : string;
};
var manualLowercase = function (s) {
return isString (s) ? s.replace (/[A-Z]/g, function (ch) {
return String.fromCharCode (ch.charCodeAt (0) | 32);
}) : s;
};
这两个函数作用是相同的吧,可是为什么要写两个呢?反正都是将大写变小写
1
doublleft 2015-11-18 15:16:35 +08:00
涨姿势
|
2
p2p 2015-11-18 15:36:00 +08:00
// String#toLowerCase and String#toUpperCase don't produce correct results in browsers with Turkish
// locale, for this reason we need to detect this case and redefine lowercase/uppercase methods // with correct but slower alternatives. if ('i' !== 'I'.toLowerCase()) { lowercase = manualLowercase; uppercase = manualUppercase; } |
3
rannnn 2015-11-18 15:59:08 +08:00 via iPhone
土耳其语的 i 大写是不是 I
比如'input'.toUpperCase() !== 'INPUT' |