Linked Questions
31 questions linked to/from Are Javascript arrays primitives? Strings? Objects?
1
vote
1
answer
208
views
Are arrays objects in JavaScript? [duplicate]
I have had discussions with seasoned programmers who do not think arrays are objects; they think that objects and arrays are of separate types of the data structure category. But, as far as I ...
1
vote
1
answer
250
views
Array and Object hybrid? [duplicate]
I played around with the Object.assign function and found out that i can create an array object fusion kinda?
the code looks like this:
var list = [1, 2, 3]
Object.assign(list, {property: true})
the ...
0
votes
1
answer
81
views
Does JavaScript convert Array into an Object internally? [duplicate]
I am aware that everything is an object in JavaScript but something struck me when i was using the console of Internet Explorer -F12 (Yes IE, not allowed to use other browsers)
If i type a sample ...
-4
votes
2
answers
181
views
Is Object and Array in Javascript the same thing? [duplicate]
I'm looking for an elegant way of understanding JavaScript array and objects.
I came to an anomaly in which I got stuck.
Since in PHP or other languages, when we make an array e.g
$a = [
admin =&...
2
votes
1
answer
106
views
Is it object, or array? Which one? [duplicate]
A colleague, by mistake wrote this code:
var parameters = [];
// some lengthy code here
parameters.firstParameter = "first parameter value";
parameters.secondParameter = "second parameter value";
He ...
1
vote
0
answers
58
views
What allows assigning array at index[some string] and underlying behavior [duplicate]
A strange behavior of array assignment at index: array[<some string>].
Let's say I have a normal array:
const arr = [1, 2, 3]; // undefined
If I type:
arr['.'] = 4; // 4
arr // (3) [1, 2, 3, .:...
0
votes
0
answers
41
views
Do arrays in JavaScript have key-attributes? [duplicate]
I was stumbling around in JavaScript and was wondering why my tests were still working, although I changed a constant from an Object to a Variable.
I'm aware that Object properties can be accessed by ...
0
votes
0
answers
31
views
Why do javascript arrays allow me to use a string as a key index? [duplicate]
Why do javascript arrays allow me to use a string as a key index?
For example,
let r = [];
r['test'] = 'testvalue' // [testvalue: 321]
Arrays can be used like objects. Is that because everything in ...
0
votes
0
answers
29
views
Adding property - value in a javascript array [duplicate]
Today i'm facing a really strange behavior, check this out !
const person = [];
person.name = "Hello World"
console.log(person) // [name: "Hello World"]
That is crazy, I just pushed some key - value ...
1037
votes
77
answers
987k
views
How can I 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 ...
user avatar
user4903
11
votes
4
answers
16k
views
Is it possible to combine optional chaining with arrays and map (in Javascript)?
I recently learned about optional chaining in Javascript and have been making use of it in a React/NodeJS project. Works great.
I noticed I have been using it with arrays map, even without thinking ...
3
votes
3
answers
13k
views
Why Object.assign works with an array?
So I was reading an article to clone an object and array. All of them mentioned that Object.assign() can be used to copy an object but no one mentioned that Object.assign() will also work to shallow ...
2
votes
4
answers
14k
views
Difference between a constructor and an Object
I definitely need some light on this.
What's the diference between:
var MY_APP = function(){
this.firstMethod = function(){
//something
};
this.secondMethod = function(){
//...
1
vote
5
answers
1k
views
JavaScript Array behaving like an object
I am trying to understand something in JavaScript.
Lets say I do the following:
let x = [];
x['Monday'] = 'Work';
x['Tuesday'] = 'More Work';
console.log(x) //[Monday: "Work", Tuesday:...
2
votes
2
answers
2k
views
update only one element of multi-dimensional array using setState
I want to change only one element of a multidimensional array
// nodes is a 2-dimensional array
// of 30 rows and 30 columns
this.state = {nodes};
// updatedNodes is a deep copy of nodes
...