An array containing multiple dimensions with labeled tags

Suppose I need an array with tag names so that I can easily call a specific row by using its tag name, like myArray['tag_one'][2] to access the 3rd element under the tag_one identifier.

Is there a way to achieve this functionality?

Perhaps something similar to:

var myArray=[
        tag_one=[1,2,3],
        tag_two=[11,22,33],
        tag_three=[111,222,333]
] 

Apologies for any mistakes in my English. Thank you in advance!

Answer №1

To create an object with different properties, you can utilize an object literal:

var myBook = {
    title: "The Great Gatsby",
    author: "F. Scott Fitzgerald",
    year: 1925
}; 

// Accessing properties using bracket notation:
console.log(myBook["title"]);  //-> The Great Gatsby

// Accessing properties using dot notation:
console.log(myBook.author);  //-> F. Scott Fitzgerald

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Import an array of dynamic modules with Webpack that are known during compilation

For my project, I have the requirement to import specific modules whose actual paths are only known during compile time. Imagine having components/A.js, components/B.js, and components/C.js. In my App.js, I need to include a subset of these modules that w ...

How to properly stop a sequence of notes using WebAudio in an asynchronous manner?

Utilizing WebAudio for playing a sequence of musical notes has been quite successful. I have a playNote function that takes note frequency, start times, and stop times for each note as input. The parameters for generating the sequence are set prior to the ...

To change the font color to red when clicked, I must create a button using HTML, CSS, and Javascript

Currently, I am utilizing CodePen to assess my skills in creating a website. Specifically, I am focusing on the HTML component. My goal is to change the font color to blue for the phrase "Today is a beautiful sunny day!" Here is the snippet of code that I ...

The default skin of video.js is disrupted by a 16:8 ratio

Incorporating videojs into my react application has presented a challenge. I have enclosed the video player in a div set to a 16:8 ratio, but unfortunately the default skin does not display properly. On the other hand, when I implement code that includes t ...

Enhance Your Website with Interactive Tooltips Using Twitter Bootstrap

In Twitter bootstrap, the default trigger for tooltips is hover. If I want to make the tooltip display on focus instead, I can add data-trigger="focus". But how do I make it so the tooltip displays both on hover and on focus? ...

Is there a way to modify the maximum size limit for a POST request package?

I am encountering an issue while attempting to send an array of bytes using a POST request. In my server-side implementation, I am utilizing Node.js and Express.js. Unfortunately, I am receiving error code 413 or the page becomes unresponsive ('Payloa ...

Error encountered when using strcpy() with a character array member in a struct causing a segmentation fault

I've defined a struct TREE as follows: typedef struct TREE { NODE *head; } TREE; Also, I have a struct NODE defined in the following way: typedef struct NODE { char boss[30]; char name[30]; struct NODE *firstChild; struct NODE * ...

Trouble with AngularJS: Updates not reflecting when adding new items to an Array

I am facing a persistent issue that I have been unable to resolve, despite researching similar problems on StackOverflow. My current project involves building an application with the MEAN stack. However, I am encountering difficulties when trying to dynam ...

Animating images on scroll using Bootstrap's utilities

Is it possible to use bootstrap for creating a responsive animation of a bicycle moving from start to end as the user scrolls down the page? Additionally, how can I incorporate a responsive dotted line using bootstrap as well? Are there any codepen exampl ...

My array contains a list, and I need to determine how to ensure that a specific element is displayed first based on a condition in the mapping

Here is the object. let newObj = { firstValue:"abc", content:[ { "value": "123", "checked": true }, { "value": "456", "checked": false }, { "value": "789", "checked": tr ...

Alas, an error has occurred with eslint npm. The elusive 404 Not Found reared its head once more when attempting to access the es

I'm currently in the process of organizing my JavaScript code and preparing to transition to TypeScript. I recently set up node.js, npm, and eslint on my Ubuntu 20.04 system. After doing so, I executed npm -init and eslint -init. $ npx eslist util.js ...

Retrieving JSON data from a URL with PHP

Attempting to retrieve JSON data from the following URL: $search_data&format=json&nojsoncallback=1 The information I am aiming to obtain based on the above link is as follows: { "places": { "place": [ { ...

I'm having trouble with my controller - not sure what the problem is

My controller seems to be malfunctioning. I have created a controller but it is not functioning properly. Even though I have reviewed it multiple times, the issue persists. Could someone please assist me with this problem? Angular Code var myPanelSearch ...

What causes Three.js OBJ conversion to render as mesh successfully but log as undefined?

I'm just getting started with Three.js and I'm experimenting a lot. Although I'm new to Javascript as well, the issue I'm facing seems to be more about variable scoping and callback function protocols than it is about Three.js itself... ...

Create a string that has been properly formatted

I need a javascript alternative to the StringEscapeUtils in java, specifically for converting input strings like: He didn't say, "Stop!" The desired output format should be: He didn't say, \"Stop!\" Is there a similar function a ...

Issue with setTimeout function when used in conjunction with an ajax call

Currently, I am developing a quiz portal where questions are organized in modules. Each module consists of 5 questions: the first 4 are text-based, and the 5th is an image-based question. Upon registering through register.php, users are directed to index. ...

Utilize Vue Component by assigning a computed property to the data source

Trying to assign a computed property value to a component's data in order to fetch and manipulate localStorage data. After mounting the component, I want to monitor changes in the localStorage. If my key is updated, I need to retrieve the new value, ...

Implementing route prefix in a combination of express and react deployment

I'm currently facing a challenge while trying to deploy a react app that utilizes router functionality with express. The react app is expected to be accessible via the /dashboard route. At first glance, everything seems to be working smoothly on the ...

I am unable to invoke a JavaScript function from PHP code

Please Note: Despite all my efforts, I have been unable to find a solution to this issue. I have scoured numerous online resources, including Stack Overflow, without success. Surprisingly, I could not locate a relevant question on Stack Overflow addressing ...

Finding the index of an object key within a JSON structure

I am attempting to retrieve the index of my selected value in order to display all deeper options. The structure of my data in JSON format is as follows: { "flow": { "startmessage": "Hello [name]", "questionmessage": "What do you have a questi ...