Use this tag for questions related to JavaScript objects.

learn more… | top users | synonyms (1)

0
votes
0answers
24 views

Javascript: Updating direction of robot using string is not working

Javascript Trying to work on a simple game of moving a robot using key L(to move left), R(to move right), F(to move forward) from a specific position on a board where it is created using 5x5 ...
3356
votes
17answers
1.0m views

How to remove a property from a JavaScript object?

Say I create an object as follows: var myObject = { "ircEvent": "PRIVMSG", "method": "newURI", "regex": "^http://.*" }; What is the best ...
1
vote
2answers
43 views

Getting url from file location using Javascript

I have a slider that uses an html file in a frame on SharePoint. Slides are changed quite frequently and this slider is being rolled out 10 more times. I am wanting to create a workflow so the end ...
2
votes
2answers
37 views

Callback for find not working-Javascript

I have written a custom callback function for Javascript's find function but that is always yielding undefined var objectsArray = [ { 'a': 1, 'b': 2, 'c': 3 }, { 'a': 41, 'b': 5, 'c': 7 }, ...
0
votes
0answers
10 views

AngularJS 1.5.8 - propsFilter with Parse Object

Is there any way to use the propsFilter, for example, with ui-select with a Javascript object (I have a ParseObject from the open-source Parse server). My existing code is: <ui-select ng-model="...
-3
votes
0answers
33 views

Trying to show only a portion of an array of objects [on hold]

I have an array of about 30 objects that i currently have getting pushed into a handlebars template. What i am trying to do is to only show the first 9 objects in that array and then have a button ...
20
votes
3answers
30k views

Angularjs merge two objects

For instance, from these two objects : var object1 = { "color": "yellow", "size": null, "age": 7, "weight": null } var object2 = { "color": "blue", "size": 51, "age": null } I want ...
451
votes
28answers
344k views
0
votes
2answers
28 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
31 views

Javascript - Property of an object has the value of NaN, even when I explicitly assign it a number value

I am making a basic platform game in my spare time, and I am currently trying to add gravity. The game runs in a canvas, and so I am using black pixels as solid objects. The sprites I am making are ...
1312
votes
28answers
846k views

Length of a JavaScript object

If I have a JavaScript object, say var myObject = new Object(); myObject["firstname"] = "Gareth"; myObject["lastname"] = "Simpson"; myObject["age"] = 21; is there a built-in or accepted best ...
1
vote
4answers
109 views

What's the difference between a regular push and an Array.prototype.push.apply

I don't quite understand the difference between the following 2 lines of code. In my code, the line with "apply" works the way I want it to, and the line with just regular push doesn't. So what is ...
0
votes
1answer
18 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
33 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
32 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
31 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
24 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
40 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
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 ...
0
votes
0answers
12 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 | ...
1
vote
1answer
90 views

How to call dll function from javascript

I am trying to integrate the thumb impression machine with my web site. Firstly Thumb Impression Machine capture the fingerprint as an input and then save input in the form of image. Now I want below ...
-2
votes
0answers
38 views

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

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) { ...
3
votes
4answers
5k views

Navigating to previous and next item in a Javascript object

I want to navigate up and down an JavaScript Object given an item of an object. An example object: var items = { "5" : ["name", "link2"], "8" : ["name 2", "link 2"], "11" : ["name 3", "link ...
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: ...
4
votes
2answers
134 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
1answer
54 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
39 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
63 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. ...
857
votes
24answers
904k views

How can I display a JavaScript object?

How do I display the content of a JavaScript object in a string format like when we alert a variable? The same formatted way I want to display an object.
-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
4answers
117 views

pushing an object onto an array from an array of objects in JavaScript

I'm trying to make a function that looks through an array of objects (first argument) and returns an array of all objects that have matching property and value pairs (second argument). Each property ...
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 ...
1
vote
2answers
3k views

JavascriptObject to string gwt

I have become a great fan of the JavaScriptOverlayTypes. so lets say, I have the followin JSON object: { "product": { "name": "Widget", "prices": { "minQty": 1, "price": 12.49 } }...
1
vote
2answers
41 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 ...
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, ...
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
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, ...
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", }, ...
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
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
39 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(...
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:...
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