For example, it would be nice if list[-1] in CoffeeScript could return the last item in the list. At first glance, it seems simple enough to implement, and would be useful. Unfortunately, any expression may be used to index into an array, so with negative array indices you would have to add a special check to every list[x] operation to ask if x is a positive number or a negative one. This would take CoffeeScript away from JavaScript semantics, and more importantly, JavaScript levels of performance—the array accesses in your inner loops would slow down considerably. For this reason, CoffeeScript doesn't add negative array indices to the language.
All Excerpts From
MacCaw, Alex. "The Little Book on CoffeeScript." O'Reilly Media, 2012-01-19. iBooks.
This material may be protected by copyright.
No comments:
Post a Comment