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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T18:10:13+00:00 2026-06-01T18:10:13+00:00

var Bar = function(){ } Bar.prototype.drawBar = function(obj){ } var bars = [];// Creating

  • 0
var Bar = function(){

}

Bar.prototype.drawBar = function(obj){ 

}

var bars = [];// Creating array 
for (i = 0;i < ar.length ;i++){
    bars[i] = [new Bar(ar[i],i)]; // Creating array of objects
    bars[i].drawBar(i);// I am looking for something like this, Currently it doesn't work
}

I have something like this, How do I draw a bar, giving a reference/index, It should draw with the measurements

  • 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-01T18:10:15+00:00Added an answer on June 1, 2026 at 6:10 pm

    You are trying to use bars[i] as if it was a Bar object, but it’s an array of objects.

    Use this to access the first object in the array:

    bars[i][0].drawBar(i);
    

    If you don’t have any use for an array of arrays, just store the objects in the array directly:

    bars[i] = new Bar(ar[i],i);
    

    Then your original code to access the object works.

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

Sidebar

Related Questions

var objs = new Array(); function Foo(a) { this.a = a $(#test).append($(<button></button>).html(click).click(this.bar)); } Foo.prototype.bar
I have a query like: var function = GetSomeExpression(); using (FooModel context = new
I show us the code: (function (){ var element = document.getElementById('bar'), hideElement = document.getElementById('foo'),
In the code: slider.init({ foo: bar }); var slider={ init:function(data){ } } If I
I have a System.Uri, e.g., var uri = new Uri(http://www.domain.com/foo/bar); How do I get
var foo = function(){}; foo.prototype.value = 5; foo.prototype.addValue = function(){ foo.value = 6; }
I have something like that: // original function Foo = function(params) { do foo...
I currently have a partial-application function which looks like this: Function.prototype.curry = function() {
If I have a function like this: function foo(_this) { console.log(_this); } function bar()
I have this object, dive : var dive = new Foo.Bar(); And Foo.Bar looks

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.