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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T18:56:20+00:00 2026-05-26T18:56:20+00:00

i have one question, i have this class in javascript: //FactVal UTIL.Classes.FactVal = function(entity,

  • 0

i have one question, i have this class in javascript:

//FactVal
UTIL.Classes.FactVal = function(entity, attribute, value) {
    this.entity = entity;
    this.attribute = attribute;
    this.value = value;
}

UTIL.Classes.FactVal.prototype.setEntity = function(entity) {
    this.entity = entity;
}

When im serializing a json string to an object of this type, i want to ask if exists the setEntity method, i have this json:

"FactVal": {
              "entity": {
               "string": "blabla"
              }
}

When i read “entity” i want to know if exists a method “setEntity” in the FactVal class, i think i have to do this: the value of ‘i’ is “FactVal” and the value of ‘j’ is “entity”.

if(UTIL.Classes[i].("set" + j[0].toUpperCase() + j.substring(1,j.length)))

and dont work, how can i do it?

Thanks.

  • 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-26T18:56:21+00:00Added an answer on May 26, 2026 at 6:56 pm

    You’re close, you want [] and you need to look at the prototype property of the constructor function, not the constructor function itself:

    if(UTIL.Classes[i].prototype["set" + j.charAt(0).toUpperCase() + j.substring(1,j.length)])
    

    (I also replaced your j[0] with j.charAt(0), not all JavaScript engines in the wild support indexing into strings like that yet.)

    Or better:

    if(typeof UTIL.Classes[i].prototype["set" + j.charAt(0).toUpperCase() + j.substring(1,j.length)] === "function")
    

    That works because you can access the property of an object either via the familiar dotted notation with a literal:

    x = obj.foo;
    

    …or via bracketed notation with a string:

    x = obj["foo"];
    // or
    s = "foo";
    x = obj[s];
    // or
    p1 = "f";
    p2 = "o";
    x = obj[p1 + p2 + p2];
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

BEFORE CHAOS I used to have this one... at the head part <script type=text/javascript>$(function()
I have a simple javascript class. One method of this class sets up a
In relation to this question ( Efficient hashCode() implementation ) I have one more
Background This question is in two parts. I have a one-way WCF operation hosted
I have a similar question to this one SQL products/productsales I want to do
I have a corollary question to This one. How can you change the spacing
I have a follow-up question to this one . I created a new form,
I have a follow up question to this one . Now that I have
This question is related to this one . I have a page table with
I have a question related to this one . I don't want to do

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.