Skip to content

compat/merge behavior differs from Lodash when merging array into object #1539

@dayongkr

Description

@dayongkr

Description

es-toolkit/compat's merge() produces different results than Lodash
when merging an array into an object property.

Reproduction

  import _ from 'lodash';
  import { merge } from 'es-toolkit/compat';
  
  // Lodash
  console.log(_.merge({ x: { a: 2 } }, { x: ['1'] }).x);
  // => ['1']
  
  // es-toolkit/compat
  console.log(merge({ x: { a: 2 } }, { x: ['1'] }).x);
  // => ['1', a: 2]

Expected

['1'] (matches Lodash)

Actual

['1', a: 2] (array with extra property a)

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions