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

68
Views
sending Map to content script in chrome extension gives empty object

I'm sending a map from my popup.js to content script but instead of a map I get an [object Object]. I tried using JSON.parse and JSON.stringify but I had a 'unexpected token O'. script for sending the map:

const mapObject=new Map();
mapObject.set("key2","vakku");
mapObject.set("key4","val4");
chrome.tabs.query({active: true, currentWindow: true}, function(tabs) {
        chrome.tabs.sendMessage(tabs[0].id, {
          from: "tpopup",
          command: "specifyAccounts"
        , tableData: mapObject,
        },function(message,sender,sendresponse){
         // stuff
        });
      });

and in the listener:

var dataset = msg.tableData;
       var datasetJS= new Map(Object.entries(dataset));
        if(typeof datasetJS!="undefined"){
          console.log(datasetJS.size);//0
          console.log(typeof datasetJS);//object
          console.log(datasetJS.toString());// [object Map]
          console.log(JSON.stringify(datasetJS));//{}
          console.log(typeof dataset);//object
          console.log(dataset.toString());[object Object]
}

Any idea what went wrong? Thank you!

about 4 years ago · Juan Pablo Isaza
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!