del Operator

In python, del list[0] will delete the first item in the list, and truncate it.

The same is not true in Transcrypt. Transcrypt translates del directly to JavaScript's delete, so you'll end up with an incoheret list if you use this operator.

Instead, using the pop operator can work.

# in regular python:
del list[0]
# in Screeps via Transcrypt:
list.pop(0)

If you need to delete a range, the JavaScript splice method can help:

# in regular python:
del list[1:3] # delete items 1 through 3, exclusive
# in Screeps via Transcrypt:
list.splice(1, 2) # delete 2 items, starting with index 1

Last updated