Passing arguments into map()

2442 views javascript

I am trying to use the map() function on an Array that returns some elements using puppeteer

The below is the code

let res = await page.evaluate(

  elementPath => {

    return Array.from(document.querySelectorAll(elementPath)).map(

      (cin, index) => {

        return {

          cinemaState: null,

          cinemaIndex: index,

          cinemaId: cin.getAttribute("data-id"),

          cinemaName: cin.getAttribute("data-name"),

          cinemaURL: cin.getAttribute("data-url")



      { s: "NSW" }



  `div[data-state=${cinemaState}] a.eccheckbox`,



I am not able to assign **cinemaState with variable s or cs. Wondering what I could be missing here

answered question

1 Answer


[1,2,3,4].map(function(num, index,wholeArray){

maps takes two argument callback and thisArg whatever u will pass at the second arg will be accessible bi this

posted this

Have an answer?


Please login first before posting an answer.