Skip to main content

All Questions

Filter by
Sorted by
Tagged with
0 votes
3 answers
54 views

Trying to check if key present in array of objects inside of an array of objects

I need a way to return true or false if in changeFields array "printLogs" key is present or not. The object is shown below. I have tried looping but somehow cant get my head to wrap around ...
myaubullion's user avatar
0 votes
1 answer
493 views

How to update nested dynamic object javascript nodejs

I'm trying to dynamically update values inside a nested object like this : mainObj = { 'Test 1': { Nested1: 'value 1', Nested2: 'value 2', Nested3: 'value 3', Nested4: 'value 4', ...
Geek65's user avatar
  • 23
3 votes
3 answers
2k views

Best way to find nested property by name in object

I have an object (dataLayer), which can increase and decrease in length, depending on how many pages you've visited. I want to: Loop through the objective and look for the property name "...
Reena Verma's user avatar
  • 1,685
-2 votes
1 answer
250 views

How to compare map values in loop with JavaScript? [closed]

Say I have const food = new Map(); const max = 0; food.set(hotdogs, 2); food.set(pizza, 8); I'd like to compare the values in my map to other values in my map, (for example: which is larger, 8 or 2?...
Tzvi2's user avatar
  • 182
2 votes
2 answers
6k views

Line break not working with jQuery .text()

I have the following code:- function data(x) { var dataList = ""; for (var key in obj) { dataList += key + ": " + obj[key] + "\n" } $('#modalText').text(dataList); ...
bob's user avatar
  • 629
5 votes
1 answer
2k views

Iterating through a javascript object to get key-value pairs

Here's my code: obj = {"TIME":123,"DATE":456} console.log(obj.TIME); console.log("---------") for (var key in obj) { console.log(key); console.log(obj.key); } It prints as the following: ...
bob's user avatar
  • 629
-1 votes
2 answers
3k views

ES6 How to convert key, value pair to string recursively in javascript?

I try to interpolate error messages, because I need it in a special text format. Whats the best practice doing that nowadays :) thanks for any help! http://codepen.io/radosch/pen/wWYPYG?editors=1111 ...
bitflorist's user avatar
1 vote
2 answers
49 views

Inserting values from an array of objects into a set of elements

I have an array of objects and would like to insert their values into a set of inputs. I thought that using jQuery's val() to mass assign these values within a few for-loops but it only returns the ...
Carl Edwards's user avatar
  • 14.4k
0 votes
4 answers
2k views

looping through array of inputs to set value, "cannot set property value of undefined"?

I'm looking for a plain-Javascript way to fix my following code: function autoFill(response) { var arr = []; arr.fn = document.getElementsByName("firstName")[1]; arr.ln = document....
tdc's user avatar
  • 5,454
2 votes
3 answers
224 views

How come for(var i in arguments) doesn't work?

I'm new to JavaScript. I'm trying to figure out why this doesn't work: function myFunction(){ document.getElementById("result").value=add(1,2); } function add(){ var sum = 0; for(var i in ...
ConditionRacer's user avatar
0 votes
1 answer
886 views

looping through key:value pairs in array to match useragent string in javascript

I have an array of key:value pairs containing a keyword found in the useragent string. I need to loop through these pairs and match each value for match to the navigator.userAgent string. I know ...
jpgr's user avatar
  • 278
162 votes
3 answers
399k views

How to loop through key/value object in Javascript? [duplicate]

var user = {}; now I want to create a setUsers() method that takes a key/value pair object and initializes the user variable. setUsers = function(data) { // loop and init user } where ...
Blankman's user avatar
  • 266k