ES6 merge object

Object.assign (target,. Sources) is to merge all the sources of the latter into target,. Is there any way to merge only the key that is not available in key, target with target?

Jul.27,2021

for reference. Consistent with the Object.assign behavior, except for the function length , this is not east-west compatible, so it does not need to be consistent; and there is no copy of Symbol .

function merge(target, src) {
    const result = {...target}
    Object.keys(target).forEach(key => {
        if (target.hasOwnProperty(key)) {
            result[key] = src[key]
        }
    })
    return result
}
MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1b40b9f-41579.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1b40b9f-41579.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?