Advertisement
Guest User

Untitled

a guest
Jun 19th, 2019
62
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.57 KB | None | 0 0
  1. This allows you to use back-access syntax to access items in an array or characters in a string.
  2.  
  3. 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.
  4.  
  5. ### Examples
  6.  
  7. ```js
  8. const arr = backAccess(['first', 'second', 'last'])
  9. arr[-1] // => "last"
  10. arr[-2] // => "second"
  11. arr[-3] // => "first"
  12.  
  13. const str = backAccess('Hello world!')
  14. str[-1] // => "!"
  15. str[-2] // => "d"
  16. str[-3] // => "l"
  17.  
  18. ```
  19.  
  20. ### Conclusion
  21.  
  22. Proxies are awesome! But maybe a bit useless in practical terms xD
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement