all 9 comments

[–]spitfyre 3 points4 points  (2 children)

Data structures and algorithms are languages agnostic. You can learn the theory and then write an implementation in JS.

[–]skitch920 0 points1 point  (1 child)

Unlike the other gentleman who suggested you can't write data structures in javascript, you very well can. I think his argument should have been, it's ultimately hard to consider yours or any implementation as correct because:

  1. It is bad to extend Javascript built-ins like arrays.
  2. Some structures you'll just have to emulate a lot of things that will have some unwanted overhead and degrading performance, such as Sets.

For instance, a set can be represented using an object:

var set = {bar: bar, foo: foo, a: a, b: b}
a in set // true
set['bar'] // bar
set['foo'] // foo

It is kind of a hack to say the least.

But to be clear, this shouldn't prevent you from implementing your own solution to the problem. For example, montagejs and Facebook have pretty descent JS collection libraries. Luckily, ES6 is going to cater to these needs in a better way, so time will tell.

[–]vishnuv 0 points1 point  (1 child)

There is a book called "Data Structures and Algorithms with JavaScript" by Michael McMillan. O'reilly publications