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();
}
);
});
});
Nov 19 at 11:13


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
    Nov 19 at 11:09






  • 4




    Objects are not built on arrays - it's the other way around.
    – CertainPerformance
    Nov 19 at 11:09










  • Maybe you mean this: typeof ; //returns object or this new String() I would rather say everything in JS is build on objects.
    – Zydnar
    Nov 19 at 11:17










  • myArr = ['this', 'is', 'an', 'array'] is actually { 0: 'this', 1: 'is', 2: 'an', 3: 'array' } behind the scenes.
    – AnonymousSB
    Nov 19 at 11:23















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();
}
);
});
});
Nov 19 at 11:13


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
    Nov 19 at 11:09






  • 4




    Objects are not built on arrays - it's the other way around.
    – CertainPerformance
    Nov 19 at 11:09










  • Maybe you mean this: typeof ; //returns object or this new String() I would rather say everything in JS is build on objects.
    – Zydnar
    Nov 19 at 11:17










  • myArr = ['this', 'is', 'an', 'array'] is actually { 0: 'this', 1: 'is', 2: 'an', 3: 'array' } behind the scenes.
    – AnonymousSB
    Nov 19 at 11:23













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 Nov 19 at 11:06









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();
}
);
});
});
Nov 19 at 11:13


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();
}
);
});
});
Nov 19 at 11:13


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
    Nov 19 at 11:09






  • 4




    Objects are not built on arrays - it's the other way around.
    – CertainPerformance
    Nov 19 at 11:09










  • Maybe you mean this: typeof ; //returns object or this new String() I would rather say everything in JS is build on objects.
    – Zydnar
    Nov 19 at 11:17










  • myArr = ['this', 'is', 'an', 'array'] is actually { 0: 'this', 1: 'is', 2: 'an', 3: 'array' } behind the scenes.
    – AnonymousSB
    Nov 19 at 11:23


















  • A 10 second google gives: eloquentjavascript.net/04_data.html, and metaltoad.com/blog/…
    – Stuart
    Nov 19 at 11:09






  • 4




    Objects are not built on arrays - it's the other way around.
    – CertainPerformance
    Nov 19 at 11:09










  • Maybe you mean this: typeof ; //returns object or this new String() I would rather say everything in JS is build on objects.
    – Zydnar
    Nov 19 at 11:17










  • myArr = ['this', 'is', 'an', 'array'] is actually { 0: 'this', 1: 'is', 2: 'an', 3: 'array' } behind the scenes.
    – AnonymousSB
    Nov 19 at 11:23
















A 10 second google gives: eloquentjavascript.net/04_data.html, and metaltoad.com/blog/…
– Stuart
Nov 19 at 11:09




A 10 second google gives: eloquentjavascript.net/04_data.html, and metaltoad.com/blog/…
– Stuart
Nov 19 at 11:09




4




4




Objects are not built on arrays - it's the other way around.
– CertainPerformance
Nov 19 at 11:09




Objects are not built on arrays - it's the other way around.
– CertainPerformance
Nov 19 at 11:09












Maybe you mean this: typeof ; //returns object or this new String() I would rather say everything in JS is build on objects.
– Zydnar
Nov 19 at 11:17




Maybe you mean this: typeof ; //returns object or this new String() I would rather say everything in JS is build on objects.
– Zydnar
Nov 19 at 11:17












myArr = ['this', 'is', 'an', 'array'] is actually { 0: 'this', 1: 'is', 2: 'an', 3: 'array' } behind the scenes.
– AnonymousSB
Nov 19 at 11:23




myArr = ['this', 'is', 'an', 'array'] is actually { 0: 'this', 1: 'is', 2: 'an', 3: 'array' } behind the scenes.
– AnonymousSB
Nov 19 at 11:23












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 Nov 19 at 11:10


























        community wiki





        Madara Uchiha
















            Popular posts from this blog

            Create new schema in PostgreSQL using DBeaver

            Deepest pit of an array with Javascript: test on Codility

            Costa Masnaga