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?










share|improve this question













marked as duplicate by Stuart, trincot arrays
Users with the  arrays badge can single-handedly close arrays questions as duplicates and reopen them as needed.

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 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















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?










share|improve this question













marked as duplicate by Stuart, trincot arrays
Users with the  arrays badge can single-handedly close arrays questions as duplicates and reopen them as needed.

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 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













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?










share|improve this question














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






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked 2 days ago









MiddleZ

316




316




marked as duplicate by Stuart, trincot arrays
Users with the  arrays badge can single-handedly close arrays questions as duplicates and reopen them as needed.

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 arrays
Users with the  arrays badge can single-handedly close arrays questions as duplicates and reopen them as needed.

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 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


















  • 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 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
















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












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.






share|improve this answer






























    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.






    share|improve this answer



























      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.






      share|improve this answer

























        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.






        share|improve this answer














        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.







        share|improve this answer














        share|improve this answer



        share|improve this answer








        answered 2 days ago


























        community wiki





        Madara Uchiha
















            Popular posts from this blog

            MongoDB - Not Authorized To Execute Command

            How to fix TextFormField cause rebuild widget in Flutter

            Npm cannot find a required file even through it is in the searched directory