lodash icon indicating copy to clipboard operation
lodash copied to clipboard

Argument Mutation in flatSpread

Open prayans opened this issue 1 year ago • 1 comments

Screenshot 2024-10-21 at 10 52 02 AM

Issue: Using Object(name) as a check to see if name is an object is not reliable since it could fail for various falsy or primitive values. Instead, use a more reliable check here.

prayans avatar Oct 21 '24 05:10 prayans

This library literally contains an isObject function. Why is that not being used here??

jdmarshall avatar Jun 13 '25 21:06 jdmarshall

x === Object(x) is utterly reliable in every JavaScript engine since its creation, and is an "isObject" replacement.

Additionally, that does not mutate x, it createst a new object wrapping x iff it's a primitive.

ljharb avatar Nov 04 '25 19:11 ljharb