Mar 05, 2016
The rest of this post describes how the example was implemented. If you'd rather just skip all that and just look at the code, it is available here.
What the example application does
An overview of the implementation
- UserView — A React component which is our View module. It displays a list of users and also allows us to delete/create users.
- UserStore — A data store which is the Model. It talks to a REST API to get a list of users, to delete a user and to create a user.
- UserIntent — The Intent object.
Feb 27, 2015
var an_array = [1, 2, 3, ]
This is what the ECMASript Language Specification says about commas in array initialisers:
Whenever a comma in the element list is not preceded by an AssignmentExpression (i.e., a comma at the beginning or after another comma), the missing array element contributes to the length of the Array and increases the index of subsequent elements. Elided array elements are not defined. If an element is elided at the end of an array, that element does not contribute to the length of the Array.
So the answer to our question would be 3 as the trailing comma would be ignored. You can confirm this by bringing up the console in developer tools in Firefox or Chrome entering the array definition and printing out its length:
> var an_array = [1, 2, 3, ] > an_array.length < 3