Use this tag for questions related to JavaScript objects.

learn more… | top users | synonyms (1)

0
votes
2answers
24 views

Filtering objects from two array of objects using lodash

I am trying to filter objects from two array of objects on the basis of name along with few conditions using lodash. Here are the arrays var param1 = [{'name': 'sa', 'value':'sample'}, {...
0
votes
0answers
35 views

Mapping objects of old to new in JavaScript

I have this function but it is having only one object in each variable but there are an array of 3 objects in input. ctrl.func = function (oldDetails, newDetails) { var ...
0
votes
0answers
7 views

ImmutableJS: merge two list of objects, without duplicating them

Supposing I have the below: var allFoods = Immutable.List(); var frenchFood = Immutable.List([ { 'type': 'french fries', 'price': 3 }, { 'type': 'petit gateau', 'price': 40 }, {...
0
votes
1answer
46 views

Returning Numeric Input as String Javascript

I am having issues with spaces. Also, dashes are needed in between numbers such as fifty-four; however, I am getting dashes behind numbers like fifty- thousand. Also, I require no blank spaces after ...
0
votes
5answers
61 views

How to find duplicate values in a JavaScript array of objects, and output only unique values?

I'm learning JS. Supposing I have the below array of objects: var family = [ { name: "Mike", age: 10 }, { name: "Matt" age: 13 }, { name: "Nancy", age: 15 }, { ...
0
votes
3answers
44 views

How to remove all getters and setters from an object in Javascript and keep pure value

I'm using a library called which takes a JS object as an input. Unfortunately, the JSONP api that I am using returns an object containing getters and setters, which this particular library does not ...
-1
votes
3answers
45 views

Property is becoming NaN [duplicate]

I have the following code for a small game server. var GameWorld = function () { this.uptime = 0; this.loop = function () { this.uptime++; }; }; var game = new GameWorld(); ...
-1
votes
3answers
38 views

Javascript: finding all objects in an array which have certain properties and values

I have an array of objects. Each object has a boolean property called available on it, along with an arbitrary number of other properties. I know the available property exists, but I have no idea what ...
0
votes
1answer
53 views

Calling Ajax method to set object properties doesn't seem to “stick” outside context of the method?

It falls to me to extend something someone else wrote years ago. I can't get it to work, and I'm not sure if it's because I haven't done much Ajax work or because I don't entirely grasp closures... I ...
-3
votes
0answers
45 views

JavaScript Array or Object to sort item list according to parameter [on hold]

` var taskName= document.getElementById('task-name'); var setDate= document.getElementById('date'); var setTime= document.getElementById('time'); var priority= document....
0
votes
1answer
19 views

Checking definedness of nested object's fields in Javascript

Take an object like this book.chapter.paragraph.sentence.word assume you want to retrieve a certain word book[6][3][15][3] to be certain to reference an existing word, do you really have to ...
0
votes
1answer
19 views

How can I access a nested class object in Javascript?

I'm using the node scheduler & it creates an object like so: { recurs: true, year: null, month: null, date: null, dayOfWeek: null, hour: null, minute: Range { start: 0, end: 59, ...
0
votes
2answers
49 views

How to combine two array objects if a key value matches in both arrays

I am trying to combine two array objects with different array objects based on flight key. If the value is matched in a2, I want to merge it with a1 and create new array. All data in a1 must be there ...
0
votes
1answer
38 views

How to merge two objects with different structure in javascript

I Have two objects with different structure, trying to merge this two objects with matched data based on a key value, and make a new object with complete data from object1 and object2. my Object1 { ...
-1
votes
0answers
32 views

Break up large json file into a series of smaller objects

I have a json file that has 7500 objects and I need to break them down into JSON objects of 100 in size. How can I go about doing this? Details: I am using JavaScript Yes we will use a loop I ...
0
votes
1answer
36 views

What does the term `functions objects` in Javascript actually mean?

After reading a lot, I still don't quite understand the term function objects in JS. From what I have read, following are my interpretations. Please correct if I'm wrong. function myfunc(x){ return ...
0
votes
3answers
31 views

Iterate through Object keys in Javascript

Having an object like this: req.body = { currency : "USD", item_name_1: "something", item_price_1: "something else", item_name_2: "something", item_price_2: "something else", ...
1
vote
2answers
36 views

How to apply an expression towards only numbers and not strings

This should be an easy one but I'm having a brain fart today. so.. var cat = { name: 'catcat', age: 6, color:'brown' } I want to return an object where only numbers get squared. So far I have.. ...
1
vote
3answers
33 views

javascript: create an array of JSON objects from linking two arrays

let's say I have two arrays: var meals: ["breakfast", "lunch", "dinner"]; var ingredients: [["eggs", "yogurt", "toast"],["falafel", "mushrooms", "fries"], ["pasta", "cheese"]; Is there an ...
-1
votes
1answer
23 views

How to destroy variable when change URL(any browser) in JavaScript or Jquery

Today use this Code but this code some time not properly work **Problem : Page refresh then call unload() but some time user change URL directly at that time not call unload() because website change....
0
votes
2answers
47 views

How to numerically sort nested keys in local storage

The Problem I've been trying to figure out how to sort my local storage object by its keys which are milliseconds. Example Code // function that saves to local storage function ...
0
votes
0answers
11 views

How to get data “out of” d3.xml(…)? [duplicate]

I use Array.push() inside a d3.xml function to gather some data from a xml. But it doesn't seem to work, my Array.length = 0 whereas the console.log SHOWS ME that my data are here... You can see it ...
0
votes
1answer
55 views

Ewa Namespace Javascript API Embedded Excel Web Part / Web App Dashboard - setParametersAsync method creates infinite loop

The setParametersAsync method takes a JavaScript object as it's first parameter. When I pass a literal object with a single value assigned to a key, the method calls it's callback function, executing ...
4
votes
3answers
36 views

Convert object with one property into parent property

I have converted javascript object from xml, this is example of object: { name: 'current name', attr1: 'attribute1', attr2: 'attribute2', address: { name: 'name1', value: { ...
0
votes
2answers
30 views

Splitting a Bill - JavaScript exercise

I'm currently learning JS, and I'm trying to work through a coding exercise. So far, I've managed to piece together the following code using plenty of resources on parts of the code offline and online....
-3
votes
1answer
27 views

javascript objects how to duplicate functionality

when I run this code d = new Date(); alert(d); I get this output: Fri Sep 30 2016 22:09:45 GMT-0400 (Eastern Daylight Time) how can I duplicate this with my own objects? instead of having to do ...
2
votes
3answers
31 views

Iterate and Enumerate Key Value Pairs of Multiple Arrays in an Object

My question is in regards to the following function: function loadConfigurations(configs){ console.log(configs); } The 'configs' object that the loadConfigurations function receives, contains ...
0
votes
2answers
29 views

How to filter options of a <select> by textfield with pure javascript onkeyup?

I have a select with some values. When the user enters a vehicle in the search box, the drop down gets filtered to the option value that matches in the search box. I am able to get this first part of ...
0
votes
2answers
31 views

Adding complex objects to an array using foreach or map with javascript

I've reviewed similar questions here on stackoverflow, read the javascript MDN, and not found comparable examples, and am asking now for advice on how to create the desired array from the given array. ...
-1
votes
2answers
29 views

Using Array.from() in JS

I am a little confused with Array.from() in JavaScript. I know/think that is turns array-like values into arrays, but why, if Array is an object, do we not have to use the 'new' keyword to instantiate ...
0
votes
3answers
40 views

Is it possible to populate an Object instance by looping through an array?

I'm making a journal app and need to create an object instance every time inputs are submitted on my html form. I want to create a loop that takes the inputs in results and converts them to values ...
0
votes
0answers
26 views

How to remove a JavaScript component (object) [duplicate]

So I have a very basic game and I need a "Restart" button to work instead of refreshing the game to restart the game. When I click the button I want to remove everything and then load the main ...
0
votes
2answers
16 views

Running an animation when a particular child element is clicked, but doing nothing on all other children

I am attempting to get the following code snippet to work the way I want it to. I only want the sub-menu to slide back to the right when the "li" element with the class "back" is selected. Right now, ...
0
votes
0answers
7 views

TableSelectDialog OData binding not executed during instantiation SAPUI5

When a TableSelectDialog is instantiated, the OData binding is not executed. It gets executed during the subsequent times. What is wrong with my implementation. Please find the MWE: eventName: ...
-1
votes
3answers
30 views

How to safely wrap an object into an array in JavaScript

I have a function that takes in an Array, iterates over it finding all Objects and displays them to the UI. In rare cases, I have to supply an Object (result from a WS as application/JSON) which is ...
0
votes
3answers
34 views

Merging values from multiple objects inside array

I have 3 separate arrays with 3 objects inside each of them: [{Index: 1}, {Index: 2}, {Index: 3}] [{Placement: 'Wall'}, {Placement: 'Roof'}, {Placement: 'Door'}] [{Color: 'GREEN'}, {Color: 'WHITE'}, {...
1
vote
0answers
31 views

jQuery variable in array path [duplicate]

I am passing a variable into a function (an array in this case). How do I use a variable in that array to select data from another array which has a key with the same name? I have tried various ...
4
votes
2answers
42 views

What happens when you instantiate a new Object(1) with a parameter in JavaScript?

What happens when you call: new Object(1) When I tried it out, it returned: [Number: 1] I want to understand what is going on there. Any info would be appreciated.
0
votes
2answers
19 views

Javascript object/function accesibility inside another one

I was looking for best solution, but I dont really what keyword should I look for. I need a bit of explanation of my problem :) Thats my code: function fluidEdge(params) { var fluid = {}; fluid....
0
votes
1answer
14 views

Keep the context of this after a click event in a function object

I've got an object with functions. Here's a simplified version: var app = { functOne: function(){ document.querySelector('button').addEventListener('click', this.functTwo); }, functTwo: ...
1
vote
2answers
49 views

Correct way to override this JavaScript class method

Apologies if this is quite an obvious, well documented one but I've not found much documentation which helps me with how I should best go about overriding a JavaScript class method when it has been ...
1
vote
3answers
21 views

JavaScript - change only SPECIFIC object field value at runtime

I have this JS code: <script type="text/javascript"> var triangle = new Object(); triangle.sideA = 3; triangle.sideB = 4; triangle.sideC = 5; triangle. getArea = function () { // ...
1
vote
1answer
8 views

Why the if statement is not accepting bracket-notation instead of dot-notation?

var contacts = [ { "firstName": "Akira", "lastName": "Laine", "number": "0543236543", "likes": ["Pizza", "Coding", "Brownie Points"] }, { "firstName": "Harry", "lastName": "...
1
vote
3answers
27 views

How to put data into multi dimensional array in js inside the loop

How can we put data into multi dimensional array or json within a loop. I know that it's possible to store multi dimensional data at one time, but I want it inside the loop as I have described in the ...
1
vote
2answers
29 views

Difference between two JavaScript classes and why prototype does't work on Emp class

(function() { var Emp = function(_name, _salary) { var name = _name; var salary = _salary return { name: name, salary: salary }; } Emp.prototype.work = ...
-1
votes
1answer
14 views

JavaScript bind arguments correctly [duplicate]

I've got the following bootstrap3 button code which is enclosed inside a container div. The button has no text apart from a plus icon. <div id="container"> ... <a type="button" ...
0
votes
5answers
44 views

adding properties to an existing object inside an array

I am picking an array with few object on it from an external file. Using: app.controller('mycontroller', function($scope, $http) { $http.get("file") .then(function(response) { $scope.lols = ...
0
votes
2answers
44 views

Convert object to array of type integer and sum the values

I want to convert JavaScript object to array of type integer and add all the values in array and convert back to object. So far I tried the following: //Convert object to array var arr = Object....
0
votes
2answers
32 views

Find and retrive object value by key, include nested objects

I am trying to find a value by key without knowing the object, include nested object, so the function will get a key and a object and return the value or undefined. This is my function: /* Iterate ...
1
vote
2answers
26 views

how javascript add property to an object?

I was reading javascript questions where i found this piece of code var a={}, b={key:'b'}, c={key:'c'}; a[b] = 123; a[c] = 456; console.log(a[b]); // o/p - 456 can anybody make me ...