Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8438509
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T07:44:17+00:00 2026-06-10T07:44:17+00:00

I am having an issue whereby I create a RegExp object in a content

  • 0

I am having an issue whereby I create a RegExp object in a content script and pass it as part of an object back to the main script using self.port.emit().
Somewhere along the way it seems to lose its identity as a RegExp and also its toString abilities. The following returns false in the main script, but true in the content script:

Object.prototype.toString.call(regexp) == '[object RegExp]';
regexp instanceof RegExp;

Interestingly for Arrays passed in the same way the following is true:

Object.prototype.toString.call(array) == '[object Array]'; 

Am I missing something?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-10T07:44:19+00:00Added an answer on June 10, 2026 at 7:44 am

    The Add-on SDK doesn’t pass objects around when you send messages, only strings – it essentially calls JSON.stringify() on one side and then JSON.parse() on the other. The result is easy to predict:

    console.log(JSON.stringify(new RegExp()));
    

    This gives you "{}". In other words, JSON.stringify() treats “custom” objects as normal objects without any properties, object prototypes and such are ignored. What you get in your main code is a plain object, same as if you call new Object().

    If you need to pass a regular expression to your main code – send regexp.source, create an actual regular expression on the other side. Sending actual objects around isn’t possible.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I having issue that content assistant / intellisense is working in methods such as
I am having an issue with a dynamic Ovi / Nokia map whereby I
I am having an issue whereby a column within a table of mine has
We are using MSDTC for SQL transactions. I am having issue with setting up
I am having the standard issue timeout exception in my production environment whereby, after
I am having an issue whereby I cannot use an objects method because of
I seem to be having an odd issue whereby every time I try to
I am having issue with my pagemethod + url rewrite. When using regular URL:
I am having issue in checking which input has been clicked using unobstructive javascript.
I was having an issue whereby my excel grab was taking the numeric values

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.