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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T01:50:55+00:00 2026-05-30T01:50:55+00:00

I want to create the following data-structure with js: folders dictionary: folder-id(guid) : ==>

  • 0

I want to create the following data-structure with js:

folders dictionary: folder-id(guid) : ==> pages dictionary

pages array: page-position(int) : ==> files dictionary

files dictionary: file-id(guid) : ==> file object

I want to know at each time how many items are in each collection.

How would you suggest me to implemet this in JS ?

Should I use array or object with dynamically added properties?

  • 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-30T01:50:56+00:00Added an answer on May 30, 2026 at 1:50 am

    Do the classes as follows.

    function HashTable() {
        var content = {};
        var count = 0;
        this.Add = function(key, value) {
            if (content.hasOwnProperty(key)) throw new Error("Key already exist");
            content[key] = value;
            count++;
        };
        this.Set = function(key, value) {
            if (!content.hasOwnProperty(key)) count++;
              content[key] = value;
        };
        this.Get = function(key) {
            if (!content.hasOwnProperty(key)) throw new Error("No such key");
            return content[key];
        };
        this.AllKeys = function() {
            var keys = [];
            for (a in content) {
                keys.push(a);
            }
            return keys;
        };
        this.Count = function() {
            return count;
        };
        this.Remove = function(key) {
            if (!content.hasOwnProperty(key)) throw new Error("No such key");
            delete content[key];
            count--;
        };
    }
    
    
    // Then you can use it as follows
    
    var folders = new HashTable();
    folders.Add(1, 10);
    alert(folders.Count());
    alert(folders.Get(1));
    folders.Remove(1);
    alert(folders.Count());
    

    It gives you a more rigid and OOP approach.

    Edit

    This ensures that your keys are unique, gives you count at any time and accepts integers and
    strings as keys.

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

Sidebar

Related Questions

following is the structure and I want to create array of this structure in
I have the following data structure and data: CREATE TABLE `parent` ( `id` int(11)
Given the following table structure: CREATE TABLE foo ( ID INT NOT NULL AUTO_INCREMENT,
I have the following data-structure as a class named Task: private: string name; int
Let's say I have the following hypothetical data structure: create table country ( country_id
I have the following table structure with live data in it: CREATE TABLE IF
I am using MySQL 5.0. I have table with following structure and data. CREATE
I want to create the following element: <exercises xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="mySchema.xsd"> If I use something
I want to create the following T-SQL statement: SELECT SUM (sa.Amount) as 'SumAmount', SUM(sa.Cost)
I want to create URL re-write rules for following URL in htaccess. http://example.com/vedios/category/fun/ ->

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.