Use this tag for questions related to JavaScript objects.

learn more… | top users | synonyms (1)

0
votes
1answer
17 views

Finding the object's name using the constructor's argument's values

So using the following part of my code, I've been trying to find the object's name ("object's name" refers to foo, bar, baz, and jar below. Sorry if that's the improper term, couldn't find any ...
0
votes
1answer
15 views

ES6 call with variable inside array that is inside an object with multiple objects or properties

Took me a lot of time to frame the title, alas it's still hard to comprehend. Anyway this is what I wanna do, but don't know how to do it, or whether it is even possible, so please enlighten me. ...
0
votes
2answers
32 views

Accesing the object's property form a nested function [duplicate]

Here is my java script code. var fiat = { make: "Fiat", model: "500", year: 1957, color: "Medium Blue", passengers: 2, convertible: false, mileage: 88000, fuel: 0, ...
0
votes
3answers
31 views

Lodash / javascript : Compare two collections and return the differences [duplicate]

I have two array of object : the element of my table are not primitive value, but complexe objects. array1 = [obj1,obj2,obj3,obj4] array2 = [obj5,obj5,obj6,obj7] I would like to compare two arrays ...
0
votes
1answer
30 views

Add property to object when it's not null

I want to update my data with patch method without using bunch of IF statements. I want to simply check if anything changed and if yes, put the data into the object and send them out. So far I've got ...
0
votes
7answers
27 views

using dot notation with more than one in javascript syntax

Could you please explain whats the mean of first[dot]second like declaration in javascript rules first.second = (function () { //... })();
1
vote
1answer
23 views

javascript Map object delete not working

This is not the actual scenario but I have to use the check function as follows with conjunction with map object. <!DOCTYPE html> <html> <head> <title></title> </...
1
vote
4answers
39 views

Remove objects from this array of object when certain criteria is met

I have this array of object in javascript. var array = [ { DATA_ID: 1, DATA_NAME: 'XX', DATA_GROUP: 2313, CODE_NO: 1 }, { DATA_ID: 6, DATA_NAME: 'YY', DATA_GROUP: 4213, ...
1
vote
1answer
38 views

How to get the values from “[object Object]”

I have an array called selectedArray. This is an array of objects, here is a sample: selectedArray :Array[1] 0:Object category_id:"8" created_at:"2016-11-04 14:14:28" lft:"17" name:"Felt Materials" ...
0
votes
0answers
11 views

Variable Scope - Losing a variable through class prototype method setting [duplicate]

So, I'm writing a class which creates dynamically named methods in itself through the code below: 1 | function Gen() { 2 | 3 | var arr = [['test'], ['test2'], ['test3']]; 4 | ...
0
votes
1answer
10 views

How to parse through array of objects and convert string numbers to integers

Working with JS. I have an array of objects. Here is a sample below. You can see that all the values are strings. However, I need to convert the lft and rgt values into integers so that I can compare ...
-2
votes
0answers
38 views

I'm not sure if I am coding this library right. Is there any standards I should follow? [on hold]

As of the current I am coding a library in JavaScript for simplifying complex data transformation methods. So far I have written the code below: (($) => { $['typeof'] = function ($a) { ...
1
vote
3answers
39 views

How can i access this object key in this conditional?

Write a function countWords that, when given a string as an argument, returns an object where keys are the words in the string, and values are the number of occurrences of that word within the string: ...
1
vote
1answer
53 views

Return key and value in a Javascript object

How would I go about returning the key and the value to a string or a smaller object: var whatIsInAName = [{ a: "a1", b: "b1" },{ a: "c1", b: "d1" },{ a: "e1", b: "f1" }]; returning something like: ...
0
votes
0answers
38 views

Search for related properties in the same object. Javascript

I need help with matching childrens in the same object based on parent ID property.... JSON: { "1": { "id": 1, "name": "My Crib", "type": "Home", "order": 0, "parent": null }, "2": { "id": 2, "name"...
1
vote
8answers
61 views

AngularJs - check if value exists in array object

var SelectedOptionId = 957; $scope.array = [{"957":"1269"},{"958":"1265"},{"956":"1259"},{"957":"1269"},{"947":"1267"}] Is there a way of checking if a value exists in an that kind of array objects. ...
-1
votes
1answer
33 views

I need to put quotation marks around a property in an object. How do i do that?

I have something that looks like this: - var array = ["119306.jpg","149426.jpg","157715.jpg","161706.jpg","171278.jpg","172313.jpg","179934.jpg","182047.jpg","182084.jpg","182261.jpg","183351.jpg","...
0
votes
0answers
22 views

How do I pass the data from a callback function to another function in JavaScript? [duplicate]

I have been experimenting with using the Open North Represent API's Node wrapper. I am unclear about how I can use its representativesLatLon request method inside of bigger function that I want to ...
0
votes
1answer
16 views

Attempting to store the return array of Object.keys(obj) in an array using javascript, but getting the error “ReferenceError: array is not defined”

What is wrong with this code? I don't understand why this line "arrKeys = Object.keys(source);" isn't returning the array as its supposed to do. function whatIsInAName(collection, source) { var arr ...
4
votes
2answers
130 views

google api waypoint need to remove dynamically waypoint from display route

I am trying to remove waypoint from google map route using button click. But there is some problem while searching and removing element and redrawing directions with available elements. Please check ...
1
vote
2answers
40 views

sessionStorage not storing original object

I have an object which I'm getting by executing a function of SDK. When I try to store the object in session storage and the retrieve the object, the retrieved object looks same as original but when I ...
0
votes
2answers
43 views

Javascript: how can I populate an array of property values dynamically?

I have an array of values, which I want to insert into a property of an object, but I'm not sure how. Here's my object. The property is called "values" (located at the very bottom), and as you can ...
0
votes
0answers
14 views

Javascript. Does it exists depth limit when object has reference to itself ? How does interpreter optimizes this case?

If I understand correctly, in code below exists recursive reference: var object = {} object.nested = object; console.log(object) In console I can see infinite reference. So, how does interpreter ...
1
vote
2answers
13 views

Append serial number property to array of objects in javascript

I have an array of objects in javascript. var obj_arr = [{ DATA_ID: 281, DATA_NAME: 'CIM', DATA_STATE: '0' }, { DATA_ID: 382, DATA_NAME: 'CIMx', DATA_STATE: '0' }, { ...
0
votes
2answers
23 views

Retain certain properties from array of objects

I would like to retain some properties from an array of javascript objects. Here is the array of objects. obj_array = [{ "CHR_ID": 1, "CHR_NAME": "Jim", "CHR_BB_TYP": 2, ...
0
votes
1answer
13 views

Remove some properties from array of javascript objects

I would like to remove some properties from an array of javascript objects. Here is the array of objects. obj_array = [{ "DATA_ID": 1, "DATA_NAME": "Jim", "DATA_BB_TYP": 2, ...
2
votes
0answers
47 views

Eloquent Javascript: what is `this` in the following example?

Looking into eloquentjavascript, in the section of Objects as interfaces, there is an example: (Outside of a function, this refers to the global scope object.) (function(exports) { var names = ["...
1
vote
2answers
31 views

Assigning javascript object to new object as copy

I have this array of object obj.arr in javascript. I assigned it to a new object. var obj_arr_new = obj.arr; The problem is that when I modify obj_arr_new, obj.arr gets modified as well. I do not ...
1
vote
1answer
19 views

Retain some objects from an array of objects that meets criteria and remove the rest

I have an array of objects in javascript. The contents look like this; obj_array = [{ "DATA_ID": 1, "DATA_NAME": "Dim", "DATA_BB_TYP": 2, "DATA_MAC": "5474", }, ...
1
vote
4answers
58 views

javascript - Grouping elements in array by properties

I am trying to filter same color objects from the below json and every color value is containing combination of two values(color and numeric value) but I just want to filter on the basis of color. ...
1
vote
2answers
37 views

Nested Destructuring on Object Assignments

With ES6 destructuring, is their any way to destructure nested objects on assignment? Here is a quick code example to show what I mean: let node = { ItemTitle: 'Title', ItemId: 5, Menu: {Item:...
1
vote
2answers
37 views

use Object.create instead of setPrototypeof

I have the following code that ensures Promise.reject returns an actual error object: export const rejectWithAnError = function(error) { if(error.constructor === Error) { return Promise.reject(...
0
votes
0answers
29 views

How to grab an objects property that is stored in an array on a click event

I have this Object and I spawn it onto the canvas after one is picked and pushed into my array. function grabObjProp(){ var randomInt = Math.floor(Math.random() * 10) + 1; goodProp = {}; ...
-1
votes
1answer
12 views

struggling with changing the context in a loop and assigning the value to object

I am looping over the object and I want to change the original "this" object values dynamically. problem is that I am getting undefined when I try to change "this" context. here is my code
1
vote
2answers
33 views

JQuery autocomplete doesn't work properly with js objects

I'm trying to use JQuery autocomplete but I cannot make it to work properly. Inputs get the values when I choose a product from the dropdown but search is not working. No matter what I type, the 2 ...
-2
votes
2answers
19 views

Is there a way to override how a JavaScript object return on call?

For example, var a = {prop1:'asd',prop2:'zxc'}; console.log(a); and the intended return is just one of the property and not all shown, like {prop1:'asd'} // or just asd Selective property are ...
0
votes
1answer
22 views

how to access incrementing json value dynamically

This is my object Object {q1: "1", q2: "1"} So far I tried: var formData = myApp.formToJSON('#personality-test-form'); formData.q+i; Im getting NaN value when submitted ...
-7
votes
1answer
43 views

what is this.e in javascript

I am learning to make library like jquery and trying to understand a piece of code where this.e is giving me hard time, where this 'e' come from and they are assigning object to it but when they ...
1
vote
3answers
52 views

Modifying node within object in javascript

I was a little confused about how to access the property className of a created Node object? var track = { mod: { el: document.body.appendChild(document.createElement('div')), el.className:...
1
vote
2answers
60 views

Checking an empty object with lodash returns false

I have an object req.user.stripe that has a value of an empty object {}. I would like to use the lodash function isEmpty() to check if this object is empty or not. When I run console.log(_.isEmpty(...
-1
votes
0answers
31 views

Javascript: object function scope [duplicate]

I wrote down that example about a trouble I know I could solve, but I don't know clearly how; I think it is strictly releated to my wrong use of Javascript scope. Here it is: function Polite() { ...
1
vote
3answers
67 views

How do i combine data values in array to create a new array

var players = [{id: 17, amount: 126}, {id: 17, amount: 45}, {id: 12, amount: 44}, {id: 12, amount: 23}]; How would i turn the above array into a new array adding the amount for each id. var newArray=...
-2
votes
1answer
38 views

loop through an object, jump out of it when the item is matched -Javascript

I want to loop through a dynamic object, match the value, if item matched, jump out of the loop... Let say have an object:{a:false:b:true,c:false} I want to do something like (with loadash), _....
0
votes
1answer
46 views

How to remove array values from an object

var obj = { a: [1, 3, 4], b: 2, c: ['hi', 'there'] } removeArrayValues(obj); console.log(obj); // --> { b: 2 } Here is my code: function removeArrayValues(obj) { for (var key in obj){ ...
2
votes
2answers
114 views

How can I use objects as keys in a JSON?

I have this neat data format which is best represented with objects as keys. So I tried to use the following JSON: { "blocks": { "stone": { { "variant": ["bricks", "smooth"] ...
0
votes
2answers
38 views

Can not access nested array in object

I have an object that is a collection of index numbers. Under each number there are two properties and an array. I am trying to write a function that will accept arguments of the index number, the ...
0
votes
1answer
34 views

Canvas animation, issue with Math calculations in my javascript code

The idea: Hi, this is my first experiment with canvas animation. I'm not sure if this concept already exists but I've dubbed my version "two-state animation". The idea is this: A map is created with ...
0
votes
2answers
36 views

Can't access individual variables with 1 main variable [jS]

my structure looks like this: var Menu = { crab : 5, lobster : 4, potato : 10, rib : 3, wings : 8 }, // foodcount1-4 represent the HTML mapping ...
1
vote
1answer
42 views

Google: “EcmaScript 5 getters and setters for properties are discouraged” Why? [closed]

According to the Google JS style guide getters and setters are discouraged. Why is this? Mozilla JS Object docs explicitly advocate using getters and setters in js. I'm confused about the ...
0
votes
2answers
35 views

Javascript- accessing properties with dot operator or bracket notation whats the difference? [duplicate]

Is their any difference on accessing object properties with the dot operator then accessing them with the bracket notation? example. var objects={ "name":"john", "age":23, "friends":["mike","harry"] }...