All Questions

552
votes
16answers
308581 views

Access / process (nested) objects, arrays or JSON

I have a (nested) data structure containing objects and arrays. How can I extract the information, i.e. access a specific or multiple values (or keys)? For example: var data = { code: 42, it...
399
votes
10answers
176480 views

Dynamically access object property using variable

I'm trying to access a property of an object using a dynamic name. Is this possible? const something = { bar: "Foobar!" }; const foo = 'bar'; something.foo; // The idea is to access something.bar, ge...
233
votes
7answers
42642 views

How can I sort arrays and data in PHP?

Due to the enormous and ever repeating amount of "How do I sort my unique snowflake of an array?" questions, this is a reference collection of basic sorting methods in PHP. Please close any questio...
4100
votes
53answers
1437341 views

What is the most efficient way to deep clone an object in JavaScript?

What is the most efficient way to clone a JavaScript object? I've seen obj = eval(uneval(o)); being used, but that's non-standard and only supported by Firefox. I've done things like obj = JSON.parse(...
178
votes
9answers
165150 views

How do I print my Java object without getting "SomeType@2f92e0f4"?

I have a class defined as follows: public class Person { private String name; // constructor and getter/setter omitted } I tried to print an instance of my class: System.out.println(myPerson)...
33
votes
4answers
15020 views

How can I access an array/object?

I have the following array and when I do print_r(array_values($get_user));, I get: Array ( [0] => 10499478683521864 [1] => 07/22/1983 [2] => email@saya.com ...
1175
votes
35answers
1155283 views

Compare two dates with JavaScript

Can someone suggest a way to compare the values of two dates greater than, less than, and not in the past using JavaScript? The values will be coming from text boxes...
663
votes
10answers
512276 views

Object comparison in JavaScript

What is the best way to compare objects in JavaScript? Example: var user1 = {name : "nerd", org: "dev"}; var user2 = {name : "nerd", org: "dev"}; var eq = user1 == user2; alert(eq); // gives false ...
369
votes
41answers
114714 views

javascript test for existence of nested object key

If I have a reference to an object - var test = {}; that will potentially (but not immediately) have nested objects, something like - { level1:{level2:{level3:'level3'}} }; what is the best wa...
409
votes
44answers
319245 views

How to determine equality for two JavaScript objects?

A strict equality operator will tell you if two object types are equal. However, is there a way to tell if two objects are equal, much like the hash code value in Java? Stack Overflow question Is the...

Previous Next