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

  • Home
  • SEARCH
  • 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 8892889
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T23:07:09+00:00 2026-06-14T23:07:09+00:00

The RegExp.exec function returns something that looks like a hybrid array . It’s an

  • 0

The RegExp.exec function returns something that looks like a hybrid array. It’s an array, but it has properties.

console.log(/d(b+)(d)/i.exec("cdbBdbsbz"));
// => ["dbBd", "bB", "d", index: 1, input: "cdbBdbsbz"]

I can call result[0], result[1], result.index, result.input, etc.

How do I make my own?

[0, 1, "a": 1] is obviously a syntax error, and {"0": 1, "1": 1, "a": 1} does give me an object I can index and access properties of, however it’s not the same as what’s returned by exec.

I tried doing it with __proto__:

arr = [1, 2, 3];
arr.__proto__.a = 1 // arr.a is 1 now

But console.log doesn’t display the property like it does when run on the result of exec, so I suspect it’s still not the same thing.

  • 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-14T23:07:10+00:00Added an answer on June 14, 2026 at 11:07 pm

    Easy enough – an array in javascript is just an object, and you can attach any properties you like to it:

    var test = ["foo","bar","baz"];
    test.index = 1;
    test.input="foobarbaz";
    console.log(test);
    

    That console.log looks identical to the one returned by regex.exec.

    Live example: http://jsfiddle.net/9rCmJ/

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

Sidebar

Related Questions

I have a javascript function that returns an array. I would like to know
/search.aspx?Search=test function getQuery(name) { var match = RegExp('[?&]' + name + '=([^&]*)').exec(window.location.search); return match
This is my code: var boo = new RegExp(\\Bis\\B,gi); var result = boo.exec(this AisA
Ok so i'm executing the following line of code in javascript RegExp('(http:\/\/t.co\/)[a-zA-Z0-9\-\.]{8}').exec(tcont); where tcont
Using regexp with tokens on cell array of strings I've got cell array of
Here's the regexp: /\.([^\.]*)/g But for string name.ns1.ns2 it catches .ns1 and . ns2
I would like to get parameter from variable that holds URL. I got the
It is common knowledge that the exec method from RegExps can get used to
So, I am trying to make a tabs menu, like this: http://flowplayer.org/tools/tabs/index.html (but i
I think that I am on the right track but I need your help.

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.