Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- This allows you to use back-access syntax to access items in an array or characters in a string.
- Algorithmically speaking, it just adds the negative integer in `arr[-1]` to the length of the array/string and tries to search for that property inside the object.
- ### Examples
- ```js
- const arr = backAccess(['first', 'second', 'last'])
- arr[-1] // => "last"
- arr[-2] // => "second"
- arr[-3] // => "first"
- const str = backAccess('Hello world!')
- str[-1] // => "!"
- str[-2] // => "d"
- str[-3] // => "l"
- ```
- ### Conclusion
- Proxies are awesome! But maybe a bit useless in practical terms xD
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement