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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T11:59:37+00:00 2026-06-16T11:59:37+00:00

I dont Why I get this error : the error is : Unable to

  • 0

I dont Why I get this error :

the error is : Unable to get Value of ‘0’ : Object is null or undefined

and this is my code :

var Box = function(width, height, type){
var top = 0,
    right = 0;
this.width = width;
this.height = height;
this.position = {
    top: top,
    right: right,
    set: function(top, right){
        this.top = top;
        this.right = right;
    }
};
this.type = type;
this.area = this.width * this.height;
this.className = "box_" + this.width + "_" + this.height;};

    var box01 = new Box(2, 2, "slideShow");
    var box02 = new Box(2, 1, "clinics");
    var box03 = new Box(1, 2, "articles");
    var box04 = new Box(1, 1, "news");
    var box05 = new Box(2, 1, "news");
    var box06 = new Box(2, 1, "clinics");

    var boxArray = [];
    boxArray.push(box01);
    boxArray.push(box02);
    boxArray.push(box03);
    boxArray.push(box04);
    boxArray.push(box05);
    boxArray.push(box06);



var BoxUtility = function(parentId) {
this.parentId = parentId;
this.boxList = Array.prototype.pop.apply(arguments);
Object.defineProperties(this, {
    totalArea: {
        get: function(){
            var x = 0;
            for(var i = 0, len = this.boxList.length; i <= len - 1; i++){
                x = x + this.boxList[i].area;
            };
            return x;
        }
    },
});};


BoxUtility.prototype.positionCalculateMasonry = function(preDefinedRows, firstColumnWidth, restColumnWidth, itemIndex){
var firstColumnArea = preDefinedRows * firstColumnWidth,
    restColumnArea = preDefinedRows * restColumnWidth,
    firstColumnAreaRemained = firstColumnArea,
    restColumnAreaRemained = restColumnArea,
    Position = function(top, right){
        this.top = top;
        this.right = right;
        this.restFirstWidth = firstColumnWidth - right;
        this.restSecondWidth = restColumnWidth - right;
    },
    firstPosition = new Position(0, 0),
    positionStack = [],
    boxStack = [],
    indexStack = [];

positionStack.push(firstPosition);

for(var i = itemIndex, len = this.boxList.length; i <= len - 1; i++){
    if(this.boxList[i].area <= firstColumnAreaRemained){
        var temp = positionStack.filter(function(el){
            return (el.restFirstWidth >= this.boxList[i].width);
        });
    } else {

    };
};};

var x = new BoxUtility(clinica ,boxArray);
x.positionCalculateMasonry(5, 3, 2, 0);

I get this error here :

return (el.restFirstWidth >= this.boxList[i].width);

I believe its about passing the this keyword in the filter method

any help? 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-06-16T11:59:39+00:00Added an answer on June 16, 2026 at 11:59 am
    BoxUtility.prototype.positionCalculateMasonry = function(preDefinedRows, firstColumnWidth, restColumnWidth, itemIndex){
    var firstColumnArea = preDefinedRows * firstColumnWidth,
        restColumnArea = preDefinedRows * restColumnWidth,
        firstColumnAreaRemained = firstColumnArea,
        restColumnAreaRemained = restColumnArea,
        Position = function(top, right){
            this.top = top;
            this.right = right;
            this.restFirstWidth = firstColumnWidth - right;
            this.restSecondWidth = restColumnWidth - right;
        },
        firstPosition = new Position(0, 0),
        positionStack = [],
        boxStack = [],
        indexStack = [],
        that = this;
    
    positionStack.push(firstPosition);
    
    for(var i = itemIndex, len = this.boxList.length; i <= len - 1; i++){
        if(this.boxList[i].area <= firstColumnAreaRemained){
            var temp = positionStack.filter(function(el){
                return (el.restFirstWidth >= that.boxList[i].width);
            });
        } else {
    
        };
    };};
    

    The problem with posters code is that the context isnt available in the callback. Whats been added is a variable ‘that’ to hold the context. Closures are then used to pass the context into the callback.

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

Sidebar

Related Questions

I dont get why this simple line of code does not work: <?php $someVariable
Internet explorer is generating this error for the code that follows: SCRIPT5007: Unable to
I get an internal server error with the following code... any suggestions: <form name="user"
I don't get this. I've searched everywhere and no one's answers have solved this
Very frustrated here. Can't get this to work and don't know why. I am
I don't get why this confirm() call fires up even though i hit no.
I don't get why it'd doing this with the 2nd feed (appearing as a
I don't get it. I created this regular expression: <span class=copy[Green|Red].*>[\s]*(.*)[\s]*<\/span> to match certain
I have been working on this for days but I don't get it so
I have a string: 'This is some random text so you don't get upset

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.