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 7399383
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T04:03:14+00:00 2026-05-29T04:03:14+00:00

I’m basically trying to create a generic object in javascript that I can use

  • 0

I’m basically trying to create a generic object in javascript that I can use to act like an associative array.
But I would like to give the object some custom members to be able to operate on the giving object. Needles to say I’m failing miserably hopefully someone can point me in the right direction.

Here is the generic object I’m talking about.

function easeArray() {
    this.valIndex = function(searchTerm,object) {
        //searchTerm+object;
        if (searchTerm in object) {
            return "true" + object[searchTerm]
        }
    }
}

So then I try to initialize it like this.

     var  myCollection = new easeArray(); 
     myCollection = {"dioxanes": 0,  "shunning": 1,  "plowed": 2,
         "hoodlumism": 3, "cull": 4,      "learnings": 5,
        "transmutes": 6, "cornels": 7,   "undergrowths": 8,
        "hobble": 9,     "peplumed": 10, "fluffily": 11,
        "leadoff": 12,   "dilemmas": 13, "firers": 14,
        "farmworks": 15, "anterior": 16, "flagpole": 17};

this works fine but when I try to do something like this:

  alert(myCollection.valIndex())

I get an error. Type Error: object does not support property or method.

Never mind that I’m not passing the values into the function I understand that, the function is not even recognize.

My end result is to have a generic object that i can initialize and fill up with key value pairs and then simply say object.valindex("searchTerm");

Any help would be greatly appreciated.

  • 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-05-29T04:03:15+00:00Added an answer on May 29, 2026 at 4:03 am

    This cannot work because on latest statement you destroy the instance of your easeArray object. Thus the array has not such method defined

    try this code instead

    var easeArray = function(obj) {
        this.obj = obj
        this.valIndex = function(searchTerm) {
            if (searchTerm in this.obj) {
                return "true" + this.obj[searchTerm];  
            } 
        }
    }
    
    var myCollection = new easeArray({
            "dioxanes": 0,  "shunning": 1,  "plowed": 2,
            "hoodlumism": 3, "cull": 4,      "learnings": 5,
            "transmutes": 6, "cornels": 7,   "undergrowths": 8,
            "hobble": 9,     "peplumed": 10, "fluffily": 11,
            "leadoff": 12,   "dilemmas": 13, "firers": 14,
            "farmworks": 15, "anterior": 16, "flagpole": 17
        });
    
        myCollection.valIndex("firers"); /* this returns "true14" */
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Basically, what I'm trying to create is a page of div tags, each has
I'm trying to create an if statement in PHP that prevents a single post
I am trying to understand how to use SyndicationItem to display feed which is
I've got a string that has curly quotes in it. I'd like to replace
I have a French site that I want to parse, but am running into
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
I'm trying to use string.replace('’','') to replace the dreaded weird single-quote character: ’ (aka
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has

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.