alsodium
V2EX  ›  问与答

angular 源码中似乎有重复的代码?

  •  
  •   alsodium · Nov 18, 2015 · 2095 views
    This topic created in 3871 days ago, the information mentioned may be changed or developed.
    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;
    };
    

    这两个函数作用是相同的吧,可是为什么要写两个呢?反正都是将大写变小写

    3 replies    2015-11-18 15:59:08 +08:00
    doublleft
        1
    doublleft  
       Nov 18, 2015
    涨姿势
    p2p
        2
    p2p  
       Nov 18, 2015
    // 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;
    }
    rannnn
        3
    rannnn  
       Nov 18, 2015 via iPhone
    土耳其语的 i 大写是不是 I
    比如'input'.toUpperCase() !== 'INPUT'
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   5413 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 63ms · UTC 07:48 · PVG 15:48 · LAX 00:48 · JFK 03:48
    ♥ Do have faith in what you're doing.