Js 2 objects merge to fetch the ones with few attributes

let a = {a:", b:""},
b = {abr > b = {abr > want to get a = {avell, b:"},
, is there an one-step way to get it? Methods like Object.assign

Nov.01,2021

Object.keys(a).forEach((item,index)=>{
    a[item] = b[item]
})

I don't understand why in attribute a, one is empty, the other is 1, and the final result is 1?

Is that what

means? For example, if there are multiple objects A, B, C, as long as there is no such property in one of the objects, then there is no such property in the resulting object?

for example, above:

Object.assign</a>

if (typeof Object.assignless != 'function') {
  // Must be writable: true, enumerable: false, configurable: true
  Object.defineProperty(Object, "assignless", {
    value: function assign(target, varArgs) { // .length of function is 2
      'use strict';
      if (target == null) { // TypeError if undefined or null
        throw new TypeError('Cannot convert undefined or null to object');
      }

      var to = new Object();

      for (var index = 1; index < arguments.length; indexPP) {
        var nextSource = arguments[index];

        if (nextSource != null) { // Skip over if undefined or null
          for (var nextKey in nextSource) {
            // Avoid bugs when hasOwnProperty is shadowed
            if (Object.prototype.hasOwnProperty.call(target, nextKey) && Object.prototype.hasOwnProperty.call(nextSource, nextKey)) {
              to[nextKey] = nextSource[nextKey];
            }
          }
        }
      }
      return to;
    },
    writable: true,
    configurable: true
  });
}

because only the least is considered, it can be looped once, and Object.assignless (a, b);

when called.
Menu