为什么immutability-helper需要这行代码

时间:2018-06-03 17:32:36

标签: javascript

源代码部分是

getAllKeys(spec).forEach(function(key) {
    if (hasOwnProperty.call(commands, key)) {
        var objectWasNextObject = object === nextObject;
        nextObject = commands[key](spec[key], nextObject, spec, object);
        if (objectWasNextObject && update.isEquals(nextObject, object)) {
            nextObject = object;
        }
    } else {
        ...
    }
})

并且update.isEquals代码是

update.isEquals = function(a, b) { return a === b; };

为什么需要nextObject = object;

isEqualstrue时,nextObject euqal object已经

0 个答案:

没有答案