C.js代码:

/**
 * 有BUG
 */

(function (global) {
    var _id;
    var _map;
    var _length;

    global.C = function () {
        _map = {};
        _length = 0;
    };

    global.C.prototype = {
        setId: function (id) {
            _id = id;
        },

        getId: function () {
            return _id;
        },

        put: function (key, value) {
            if (!_map.hasOwnProperty(key)) {
                _length++;
            }
            _map[key] = value;
        },

        get: function (key) {
            if (_map.hasOwnProperty(key)) {
                return _map[key];
            }
            return null;
        },
    };

    global.C.prototype.constructor = global.C;

})(window);
View Code

相关文章:

  • 2022-01-01
  • 2021-12-09
猜你喜欢
  • 2021-11-22
  • 2021-05-03
  • 2021-11-16
  • 2021-06-12
  • 2021-06-14
相关资源
相似解决方案