Questions tagged [javascript-objects]

Use this tag for questions related to JavaScript objects.

In general an object is any entity that can be manipulated by commands in a programming language. An object can be a value, a variable, a function, or a complex data-structure. In object-oriented programming, an object refers to an instance of a class.

In JavaScript, almost "everything" is an object.

  • Booleans can be objects (or primitive data treated as objects)
  • Numbers can be objects (or primitive data treated as objects)
  • Strings can be objects (or primitive data treated as objects)
  • Dates are always objects
  • Maths are always objects
  • Regular expressions are always objects
  • Arrays are always objects
  • Functions are always objects
  • Objects are objects

This tag is specific to language so JavaScript-objects.

See also:

  • (Used as template for creating new objects)
  • (Object-oriented programming)

Attribution: https://stackoverflow.com/tags/object/info

Links

7142 questions
1
vote
2 answers

Difference between __proto__ and [[prototype]] in Global-Object?

In Browser there are some Global-Objects pre-built (Objects, String, Number, Date, etc). Mother of all such global-objects is "Object". As, this Object is the prototype of nearly all of the data-types present in JS (except only 2 - null and…
Deadpool
  • 7,811
  • 9
  • 44
  • 88
1
vote
2 answers

Get item from js object with partially known key

Let's say you dont know the numbers before the letter here. var obj = {'1234 x': 1, '32145 y': 2} How would you retrieve the value 1 from this object. The normal way of doing this would be: obj['1234 x'] // 1 But what if you only knew part of the…
Bledder
  • 59
  • 8
1
vote
2 answers

Split string based blank lines and create objects based on separator

I'm trying to create a very rudimentary parser that would take a multi-line string and convert that into an array containing objects. The string would be formatted like this: title: This is a title description: Shorter text in one line image:…
tobiasg
  • 983
  • 4
  • 17
  • 35
1
vote
2 answers

How to store multiple values in to objects within an array

Problem: I have an api and each object within the api doesn't have a value. I would like to add a unique value to each object within the array so that I can create a function and use 'e.target.value' with event listeners. I'm doing this in…
1
vote
1 answer

Building Json Object from Vue input fields

Im trying to generate a JSON object with a vue method and using vue input data fields to build part of the JSON object. My input files accept a key and a value and i have two default values 'zone' and 'capping'. My goal is for the JSON object to be…
jfr01
  • 107
  • 1
  • 11
1
vote
4 answers

Javascript Object method value not showing with console.log of the object

I'm a bit confused with objects in JavaScript... I wrote an object: const gix = { firstName: "John", lastName: "Johnson", yearOfBirth: 2000, profession: "IT", friends: ["Mark", "Luke", "John"], driversLicence: true, age: function ()…
Igor Jevremovic
  • 169
  • 1
  • 2
  • 9
1
vote
1 answer

Grouping by an Object in a BST

I have a large BST of objects (over 200k) and I need to group all of them by their name into single ones that combine the stocks and take the average of costs accordingly. If the stock reaches below or equal to zero I need to remove it from the BST…
1
vote
4 answers

Deleting a row from a JavaScript object if it matches with all properties

I am trying to delete a row from an object if that row has the same values as the property I want to delete. This is my attempt and it works, just wondering if there is a more efficient way airport_data_1 =…
bombombs
  • 593
  • 1
  • 13
1
vote
0 answers

How to detect usage of `{}` in JS?

It is possible to detect the usage of {} in JS code with test framework Jasmine by spying on a certain internal JS method / property? For example: describe('tests', () => { it('test1', async () => { const spy = spyOn(Object,…
Manuel
  • 14,274
  • 6
  • 57
  • 130
1
vote
2 answers

How to split and get till 6 digit after the decimal of logitude in javascript?

I am new to javascript and trying something with longitude coordinate. I have 3 longitudes and I want to split and store them till 6 digits after the decimal point I am able to do only one of them at a time which is not good as these numbers can…
Shivani
  • 63
  • 9
1
vote
1 answer

How to parse duplicate data in a list of objects based on multiple keys having the same value, where one key has a value of an array of objects

As the title states, I am trying to store a list of duplicate objects based on specific key:value pairs being the same. The goal is to parse the information and return a list of duplicate items. A duplicate item is when the ID , title, items are a…
dfx99
  • 23
  • 4
1
vote
2 answers

parsing out data from an object into two other objects by using an array

Trying to parse out airport data into two by using the array selected_city_codes. So airport data would be into two parts, one with only the selected city codes and the other without the city codes. I tried to attempt this using modify_airport_data…
bombombs
  • 593
  • 1
  • 13
1
vote
3 answers

Replace a string in array of objects in typescript

I have got a list of array objects as shown below [ { "subjectID": 1 "Chosen" : "{subjectsChosen:Python,java,Angular}" "password": "{studentpw:123456abcd}" }, { "subjectID": 2 "Chosen" : "{subjectsChosen:SQL,Rprogram,React}" …
1
vote
1 answer

What's the most succinct syntax to preserve only specific keys from a large JavaScript object?

In other words, I want to clean objects by dropping most of their keys. Say a third party API returns JSON with a large number of of attributes you don't care about. obj = { name: ..., id: ..., description: ..., blah: ..., bloop: ..., …
Antrikshy
  • 2,918
  • 4
  • 31
  • 65
1
vote
1 answer

How can I find & groups pairs from an array while changing the original array?

So for ex. I have this array with these values : let arr = [1, 2, 3, 3, 3, 4, 4]; How can I get a new arr as : let newArr = [3, 3, 4, 4]; while at the same time the original array should be changed as : let arr = [1, 2, 3]; one 3 is left behind…
Rabten
  • 92
  • 10
1 2 3
99
100