JavaScript Objects built on arrrays [duplicate]
up vote
-1
down vote
favorite
This question already has an answer here:
Why can I add named properties to an array as if it were an object?
7 answers
Difference between array & object in js?
2 answers
associative array versus object in javascript
7 answers
From my readings, in JavaScript:
Objects = Hash Tables, which are build on Arrays. However, it is commonly said that Arrays are Objects in JS. How are these two concepts reconciled?
javascript arrays hash hashtable javascript-objects
marked as duplicate by Stuart, trincot
StackExchange.ready(function() {
if (StackExchange.options.isMobile) return;
$('.dupe-hammer-message-hover:not(.hover-bound)').each(function() {
var $hover = $(this).addClass('hover-bound'),
$msg = $hover.siblings('.dupe-hammer-message');
$hover.hover(
function() {
$hover.showInfoMessage('', {
messageElement: $msg.clone().show(),
transient: false,
position: { my: 'bottom left', at: 'top center', offsetTop: -7 },
dismissable: false,
relativeToBody: true
});
},
function() {
StackExchange.helpers.removeMessages();
}
);
});
});
2 days ago
This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.
add a comment |
up vote
-1
down vote
favorite
This question already has an answer here:
Why can I add named properties to an array as if it were an object?
7 answers
Difference between array & object in js?
2 answers
associative array versus object in javascript
7 answers
From my readings, in JavaScript:
Objects = Hash Tables, which are build on Arrays. However, it is commonly said that Arrays are Objects in JS. How are these two concepts reconciled?
javascript arrays hash hashtable javascript-objects
marked as duplicate by Stuart, trincot
StackExchange.ready(function() {
if (StackExchange.options.isMobile) return;
$('.dupe-hammer-message-hover:not(.hover-bound)').each(function() {
var $hover = $(this).addClass('hover-bound'),
$msg = $hover.siblings('.dupe-hammer-message');
$hover.hover(
function() {
$hover.showInfoMessage('', {
messageElement: $msg.clone().show(),
transient: false,
position: { my: 'bottom left', at: 'top center', offsetTop: -7 },
dismissable: false,
relativeToBody: true
});
},
function() {
StackExchange.helpers.removeMessages();
}
);
});
});
2 days ago
This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.
A 10 second google gives: eloquentjavascript.net/04_data.html, and metaltoad.com/blog/…
– Stuart
2 days ago
4
Objects are not built on arrays - it's the other way around.
– CertainPerformance
2 days ago
Maybe you mean this:typeof ; //returns object
or thisnew String()
I would rather say everything in JS is build on objects.
– Zydnar
2 days ago
myArr = ['this', 'is', 'an', 'array']
is actually{ 0: 'this', 1: 'is', 2: 'an', 3: 'array' }
behind the scenes.
– AnonymousSB
2 days ago
add a comment |
up vote
-1
down vote
favorite
up vote
-1
down vote
favorite
This question already has an answer here:
Why can I add named properties to an array as if it were an object?
7 answers
Difference between array & object in js?
2 answers
associative array versus object in javascript
7 answers
From my readings, in JavaScript:
Objects = Hash Tables, which are build on Arrays. However, it is commonly said that Arrays are Objects in JS. How are these two concepts reconciled?
javascript arrays hash hashtable javascript-objects
This question already has an answer here:
Why can I add named properties to an array as if it were an object?
7 answers
Difference between array & object in js?
2 answers
associative array versus object in javascript
7 answers
From my readings, in JavaScript:
Objects = Hash Tables, which are build on Arrays. However, it is commonly said that Arrays are Objects in JS. How are these two concepts reconciled?
This question already has an answer here:
Why can I add named properties to an array as if it were an object?
7 answers
Difference between array & object in js?
2 answers
associative array versus object in javascript
7 answers
javascript arrays hash hashtable javascript-objects
javascript arrays hash hashtable javascript-objects
asked 2 days ago


MiddleZ
316
316
marked as duplicate by Stuart, trincot
StackExchange.ready(function() {
if (StackExchange.options.isMobile) return;
$('.dupe-hammer-message-hover:not(.hover-bound)').each(function() {
var $hover = $(this).addClass('hover-bound'),
$msg = $hover.siblings('.dupe-hammer-message');
$hover.hover(
function() {
$hover.showInfoMessage('', {
messageElement: $msg.clone().show(),
transient: false,
position: { my: 'bottom left', at: 'top center', offsetTop: -7 },
dismissable: false,
relativeToBody: true
});
},
function() {
StackExchange.helpers.removeMessages();
}
);
});
});
2 days ago
This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.
marked as duplicate by Stuart, trincot
StackExchange.ready(function() {
if (StackExchange.options.isMobile) return;
$('.dupe-hammer-message-hover:not(.hover-bound)').each(function() {
var $hover = $(this).addClass('hover-bound'),
$msg = $hover.siblings('.dupe-hammer-message');
$hover.hover(
function() {
$hover.showInfoMessage('', {
messageElement: $msg.clone().show(),
transient: false,
position: { my: 'bottom left', at: 'top center', offsetTop: -7 },
dismissable: false,
relativeToBody: true
});
},
function() {
StackExchange.helpers.removeMessages();
}
);
});
});
2 days ago
This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.
A 10 second google gives: eloquentjavascript.net/04_data.html, and metaltoad.com/blog/…
– Stuart
2 days ago
4
Objects are not built on arrays - it's the other way around.
– CertainPerformance
2 days ago
Maybe you mean this:typeof ; //returns object
or thisnew String()
I would rather say everything in JS is build on objects.
– Zydnar
2 days ago
myArr = ['this', 'is', 'an', 'array']
is actually{ 0: 'this', 1: 'is', 2: 'an', 3: 'array' }
behind the scenes.
– AnonymousSB
2 days ago
add a comment |
A 10 second google gives: eloquentjavascript.net/04_data.html, and metaltoad.com/blog/…
– Stuart
2 days ago
4
Objects are not built on arrays - it's the other way around.
– CertainPerformance
2 days ago
Maybe you mean this:typeof ; //returns object
or thisnew String()
I would rather say everything in JS is build on objects.
– Zydnar
2 days ago
myArr = ['this', 'is', 'an', 'array']
is actually{ 0: 'this', 1: 'is', 2: 'an', 3: 'array' }
behind the scenes.
– AnonymousSB
2 days ago
A 10 second google gives: eloquentjavascript.net/04_data.html, and metaltoad.com/blog/…
– Stuart
2 days ago
A 10 second google gives: eloquentjavascript.net/04_data.html, and metaltoad.com/blog/…
– Stuart
2 days ago
4
4
Objects are not built on arrays - it's the other way around.
– CertainPerformance
2 days ago
Objects are not built on arrays - it's the other way around.
– CertainPerformance
2 days ago
Maybe you mean this:
typeof ; //returns object
or this new String()
I would rather say everything in JS is build on objects.– Zydnar
2 days ago
Maybe you mean this:
typeof ; //returns object
or this new String()
I would rather say everything in JS is build on objects.– Zydnar
2 days ago
myArr = ['this', 'is', 'an', 'array']
is actually { 0: 'this', 1: 'is', 2: 'an', 3: 'array' }
behind the scenes.– AnonymousSB
2 days ago
myArr = ['this', 'is', 'an', 'array']
is actually { 0: 'this', 1: 'is', 2: 'an', 3: 'array' }
behind the scenes.– AnonymousSB
2 days ago
add a comment |
1 Answer
1
active
oldest
votes
up vote
0
down vote
Objects are not built on arrays. Objects have their own optimizations.
In general:
- Objects are for "structs", structures of predictable "shape" and keys known in advance (even though they can be used with dynamic keys, you should use Maps for that. See below).
- Arrays are for lists (and queues, and stacks), structures where the keys are numbers, or where the order of elements matters. Arrays are "special" objects, not the other way around. (You can put string-based properties on an array, just like any object. Please don't do that though).
Maps are for hash tables/dictionaries, structures where the keys are dynamic and not known in advance.
add a comment |
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
0
down vote
Objects are not built on arrays. Objects have their own optimizations.
In general:
- Objects are for "structs", structures of predictable "shape" and keys known in advance (even though they can be used with dynamic keys, you should use Maps for that. See below).
- Arrays are for lists (and queues, and stacks), structures where the keys are numbers, or where the order of elements matters. Arrays are "special" objects, not the other way around. (You can put string-based properties on an array, just like any object. Please don't do that though).
Maps are for hash tables/dictionaries, structures where the keys are dynamic and not known in advance.
add a comment |
up vote
0
down vote
Objects are not built on arrays. Objects have their own optimizations.
In general:
- Objects are for "structs", structures of predictable "shape" and keys known in advance (even though they can be used with dynamic keys, you should use Maps for that. See below).
- Arrays are for lists (and queues, and stacks), structures where the keys are numbers, or where the order of elements matters. Arrays are "special" objects, not the other way around. (You can put string-based properties on an array, just like any object. Please don't do that though).
Maps are for hash tables/dictionaries, structures where the keys are dynamic and not known in advance.
add a comment |
up vote
0
down vote
up vote
0
down vote
Objects are not built on arrays. Objects have their own optimizations.
In general:
- Objects are for "structs", structures of predictable "shape" and keys known in advance (even though they can be used with dynamic keys, you should use Maps for that. See below).
- Arrays are for lists (and queues, and stacks), structures where the keys are numbers, or where the order of elements matters. Arrays are "special" objects, not the other way around. (You can put string-based properties on an array, just like any object. Please don't do that though).
Maps are for hash tables/dictionaries, structures where the keys are dynamic and not known in advance.
Objects are not built on arrays. Objects have their own optimizations.
In general:
- Objects are for "structs", structures of predictable "shape" and keys known in advance (even though they can be used with dynamic keys, you should use Maps for that. See below).
- Arrays are for lists (and queues, and stacks), structures where the keys are numbers, or where the order of elements matters. Arrays are "special" objects, not the other way around. (You can put string-based properties on an array, just like any object. Please don't do that though).
Maps are for hash tables/dictionaries, structures where the keys are dynamic and not known in advance.
answered 2 days ago
community wiki
Madara Uchiha
add a comment |
add a comment |
A 10 second google gives: eloquentjavascript.net/04_data.html, and metaltoad.com/blog/…
– Stuart
2 days ago
4
Objects are not built on arrays - it's the other way around.
– CertainPerformance
2 days ago
Maybe you mean this:
typeof ; //returns object
or thisnew String()
I would rather say everything in JS is build on objects.– Zydnar
2 days ago
myArr = ['this', 'is', 'an', 'array']
is actually{ 0: 'this', 1: 'is', 2: 'an', 3: 'array' }
behind the scenes.– AnonymousSB
2 days ago