in Python, you can get a list like this (array in JavaScript)
a = ["one", "two", "three"]
print(a[:]) # ["one", "two", "three"]
I'm wondering how I can do this too but in JavaScript. If it is possible, please tell me :)
In python, a[:] creates a shallow copy of the array. The equivalent in JS is [...a].
If you just want to get the first two elements, you can use a.slice(0, 2) which returns a new array. The slice method goes from the starting index (inclusive) to the ending index (non-inclusive).
a[:]does a shallow copy of a, then the equivalent would be[...a][:]) or slice (the general concept) the Javascript array. And having figured this out, you are well on your way to using a search engine to find an answer.