Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

250
Views
Why doesn't Lodash's map method work in implicit chains?

Given an object that looks like this:

let obj = { mytest: [{ mytest2: 123 }] }

I would have thought I could use the implicit chain like this:

_(obj).get('mytest').map('mytest2').value();

But I get an error:

VM922:1 Uncaught TypeError: mytest2 is not a function
    at Array.map (<anonymous>)
    at <anonymous>:1:22
(anonymous) @ VM922:1

It seems to expect the map parameter to be a function. If I use the explicit chain method then it does seem to work.

_.chain(obj).get('mytest').map('mytest2').value();
[123]

What's going on here? I'm using lodash 4.17.15.

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

The _(obj) is not an "implicit chain", it's a use-once object that wraps a value to make lodash functions available with method syntax. _(obj).get('mytest') is the same as _.get(obj, 'mytest'), and returns the raw [{ mytest2: 123 }] array. The .map method you're calling is not _.map, it's the array map method which requires a function argument. You also wouldn't need to call .value() on the return value.

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!