JSLint Error: Unexpected 'this'

后端 未结 6 1509
野趣味
野趣味 2020-12-03 01:02

Having trouble understanding why JSLint is surprised by my use of this in the following code:

6条回答
  •  野趣味
    野趣味 (楼主)
    2020-12-03 01:18

    'use strict';
    
    var SudoConstructor = (function () {
    
        /* We need bind, < IE9 needs a (tiny) polyfill */
    
        function protoEsqDeclare(sudoThis) {
            return sudoThis;
        }
    
        function protoEsqSet(sudoThis, newValA, newValB) {
            sudoThis.valA = newValA;
            sudoThis.valB = newValB;
        }
    
        function instanceCreator(valA, valB) {
            var sudoThis = {
                valA: valA,
                valB: valB
            };
    
            return {
                declare: protoEsqDeclare.bind(null, sudoThis),
                set: protoEsqSet.bind(null, sudoThis)
            };
    
        }
    
        return instanceCreator;
    
    }());
    

提交回复
热议问题