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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T18:22:16+00:00 2026-05-24T18:22:16+00:00

function Card(styleAttr, cardInfo) { //Attributes this.styleAttr = styleAttr; this.cardInfo = cardInfo; //Functions constructCard(this.styleAttr); }

  • 0
function Card(styleAttr, cardInfo)
{
    //Attributes
    this.styleAttr = styleAttr;
    this.cardInfo = cardInfo;

    //Functions


    constructCard(this.styleAttr);
}

function constructCard(styleAttr) {

    var cardCSS = {
                    'width':styleAttr.width,
                    'height':styleAttr.height,
                    'background-color':'black'
                  }


    $('<div class="Card"></div>').appendTo('body').css(cardCSS);
}

Hi, this Card class get’s two other object’s as it’s parameters. One of them is styleAttr which contains a property named ‘width’. Unless I pass this object to the constructCard, I cannot access the styleAttr.width property. The above example works. But if I do this:

function constructCard() {

    var cardCSS = {
                    'width': this.styleAttr.width, //Undefined
                    'height':styleAttr.height,
                    'background-color':'black'
                  }


    $('<div class="Card"></div>').appendTo('body').css(cardCSS);
}

Mostly code in other languages so I’m not sure, do I have to bind the function constructCard to the class to be able to access it’s properties or am I forced to pass the object’s to get the values. Or am I supposed to make them global variables?

It must be something simple I didn’t catch from the Moz Doc’s.

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-24T18:22:17+00:00Added an answer on May 24, 2026 at 6:22 pm

    Nothing wrong with plain old prototype inheritance:

    function Card(styleAttr, cardInfo) {
        //Attributes
        this.styleAttr = styleAttr;
        this.cardInfo = cardInfo;
    }
    
    Card.prototype.constructCard = function () {
    
        var cardCSS = {
                        'width': this.styleAttr.width,
                        'height': this.styleAttr.height,
                        'background-color':'black'
                      };
    
    
        $('<div class="Card"></div>').appendTo('body').css(cardCSS);
    }
    

    Then:

    var card_0 = new Card(..., ...)
    card_0.constructCard();
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

function getItemDialogContent(planItemType) { var oDialogContent = $('<div/>').append($('#cardDialogHelper').html()).addClass(card); if (planItemType) { oDialogContent.find('#cardDialogHeader').addClass(planItemType).find('#dialogTitle').html(planItemType); oDialogContent.find('#cardDialogCustomFields').html($('#' + planItemType
I have this part of code in my application. card.getcard(command, function(toproceed,resultscard) { console.log('entry other
I found this simple function to return the 4 most common credit card types.
function Obj1(param) { this.test1 = param || 1; } function Obj2(param, par) { this.test2
function check(id){ var _id = document.getElementById(id); url = test.php?check=1&id= + _id; } i want
Why am I getting this error: Catchable fatal error: Object of class Card could
So, i'm attempting simple card game. I have player class with draw function, and
// function scoreHandArray scores your hand function scoreHandArray(hand) { var score = 0; for
Controller function delete_payment($payment_id) { $this->sale_lib->delete_payment($payment_id); $this->_reload(); } View <?php echo anchor(sales/delete_payment/$payment_id,'['.$this->lang->line('common_delete').']');?> It is possible
I am developing a card game. In this card game the player can set

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.