Hacker News new | past | comments | ask | show | jobs | submit login

Can anyone summarize what the resulting syntax looks like?



There's a table in the GitHub repository that shows the inputs and outputs for various equivalent slices in JavaScript and Python [1]. If you're familiar with the Python slicing syntax, that should make the syntax mapping fairly clear. The way to translate a Python slice definition to JavaScript is to use double square brackets instead of single ones and to replace the colons with commas. So array[::-1] becomes array[[,,-1]], array[3:] becomes array[[3,]], etc.

[1] - https://github.com/intoli/slice#for-people-who-know-python-a...




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: