0

I am giving interview for frontend development(React JS), I am doing my final year. Today I gave one interview, in that interviewer asked me to go to lodash site and asked to search for get, and I get below example. For the below example he asked to write JS function by uisng es6. I couldn't get the question, I tried hard to understand it, most of the solution is inside either array or in object of array. Here the values are like Array inside object. Could any help me to understand this. Kindly teach me how to access the value of {c} by using ES6 or vanilla JS. Thanks in advance.

var object = { 'a': [{ 'b': { 'c': 3 } }] };

_.get(object, 'a[0].b.c');

// => 3

dev_to_be
  • 1
  • 5
  • 1
    I'm not sure I understand, what do you mean by "below example" in your question? The code you've shown is already JS code. Are you asking how to implement the lodash `_.get()` method using vanilla JS? – Nick Parsons Jun 19 '22 at 09:46
  • @Nick Parsons , yes. – dev_to_be Jun 19 '22 at 09:53

0 Answers0