Will these parameters be skipped when the source objects of Object.assign () are null and undefined? What happened?

let result = Object.assign({ position: "" }, null, undefined, { name: "" });
// { position: "", name: "" }
On

MDN, it looks like https://developer.mozilla.org.

.
Note that Object.assign does not skip source objects with values of null or undefined.

Ruan Yifeng"s article reads as follows: http://es6.ruanyifeng.com/-sharpdo.

if the non-object parameter appears at the location of the source object (that is, not the first parameter), the processing rules are different. First, these parameters are converted to objects, and if they cannot be converted to objects, they are skipped. This means that if undefined and null are not in the first parameter, no error will be reported.

what happens when the source objects of Object.assign () are null and undefined?

Jan.10,2022

if you want to know how it works, click Specification

from below mdn.
If nextSource is undefined or null, let keys be an empty List.

let result = Object.assign ({position: 'New Zealand'}, null, undefined, {name: 'Zhang'});

is equivalent to:

let result = Object.assign ({position: 'New Zealand'}, {name: 'Zhang San'});

and mdn said null and undefined, Ruan Yifeng said

if non-object parameter is out,

non-object is not just null and undefined,

Menu