Sunday 21 May 2017

How to pass data from one function to another function that is an argument of the first function

In the below example, when using getData();, is it possible to access the data contained in its object map within a new function – ie. useData(); – that is an argument of getData();?

const getData = (useData) => {

  const myData = {
    0: { title: 'Hello' },
    1: { title: 'World!' }
  };

  Object.keys(myData).map((item) => {
    useData();
  });
}

getData(console.log(
  /**
   * Somehow access data represented by `myData` and `item`
   * in above object map along the lines of `myData[item].title` 
  */
));



via lukebm

No comments:

Post a Comment