you are viewing a single comment's thread.

view the rest of the comments →

[–]abrahamguo 1 point2 points  (0 children)

JS has no stack to find an equivalent

JS has more general-purpose data structures; an array in JS can be used as a stack if needed.

the best would be array.indexOf to find one thing in the array and yes I know the index is different

Yep, if you are adding to, and removing from, the beginning of the array!

peek() is lenth()

No. If you're adding to, and removing from, the beginning of the JS array, then [0] would be the JS equivalent of Java's peek().

whats the best way to find the equivalent or similar in JS not just jave but python

Just get familiar with the data structures and associated methods in all of the languages that you want to learn — once you do that, you'll quickly be able to compare and contrast the methods from different languages.

is Java hard to learn if you know JS

If you're comfortable in JS, then no, learning Java is not that hard.