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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T03:50:06+00:00 2026-06-07T03:50:06+00:00

I am wondering if i can get the object property using array. I am

  • 0

I am wondering if i can get the object property using array. I am getting ‘undefine’ value for this.label[i].xOffset. Any suggestions?

function label() {
    var lbl = this;
    lbl.rText;
    lbl.precision =1;
    lbl.prefix = '';
    lbl.suffix = '';
    lbl.xOffset = this.width/2;
    lbl.yOffset = this.height*82/100    
}
this.NoOfneedles=2;
if (this.NoOfneedles > 1) {
    this.label = [];
    for (i=0;i<this.NoOfneedles;i++) {
        this.label[i]=new label();
        alert("label xOffset:"+this.label[i]+this.label[i].xOffset);
    }
}
  • 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-07T03:50:07+00:00Added an answer on June 7, 2026 at 3:50 am

    Your label object has no width and height properties and already others said you that but if you just define width and height inside your constructor then it could be written as follows

    function Label() {
       var lbl = this;
       lbl.width=window.outerWidth;
       lbl.height=window.outerHeight;
       lbl.precision =1;
       lbl.prefix = '';
       lbl.suffix = '';
       lbl.xOffset = lbl.width/2;
       lbl.yOffset = lbl.height*82/100    
    }
    
    this.NoOfneedles=2;
    if (this.NoOfneedles > 1){
        this.label = [];
        for (i=0;i<this.NoOfneedles;i++){
            this.label[i]=new Label();
            alert ("label xOffset:"+this.label[i].xOffset);
        }
    }
    

    Remember this refers to current object and you are using this.width/2; inside your constructor so this=Label and I’ve changed the label to Label and outside the constructor/in global scope this refers to default global object window and in the global scope this.someVar and someVar is same because window is the default global object and by default we don’t need to use it so we can use document.getElementbyId instrad of window.document.getElementbyId.

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

Sidebar

Related Questions

I'm using VS 2010, and I'm wondering how I can get my c++ program
I'm wondering if there's any reasonable way to get a reference to an object
Hey, I'm wondering how I can get the class names dynamically using jquery for
I'm wondering how I can get my textbox to only accept digits and dots,
I was wondering how I can get the graphics card model/brand from code particularly
I am wondering how I can get the document title in LaTex, for use
I am wondering how I can get all the files with File Info and
I am just wondering how i can get the error causing LoginUser function to
I was just wondering how I can get a single tap to undo the
I am fairly new to Android programming and was wondering how I can get

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.