Tuesday, January 16, 2018

A Splice that is not a Splice

Often when a language just evolves over the years, it go in a direction which would never had occurred if the language was developed from scratch.  Such is the case of JavaScript and 'splice' being used for a delete.  When can a 'splice' become a delete?  We all know what the word 'splice' means and what it implies.  However, in the case of JavaScript is has become a delete.

  1. var myArray = [1, 2 , 3]; // [1, 2, 3]
  2. myArray.splice(1,1); // [1, 3]
The word splice has now become a delete and see to be a pretty common practice in the JavaScript community.

Monday, January 15, 2018

Using Default Exports


I don't really like them to much.  Yes they are flexible; but when you go looking through code to find where they are used, the only way to be sure that you find them all is to do the following:
  1. Search for the file name.
  2. Look at each import and see if it is using the default.
  3. Use the name of the default to search in the file
I prefer to used the named include.  Using the named to look through code is more straightforward.
  1. Search the code for the name of exported.
  2. All references to it will show up include the import.
The 'named' import gives a nice view of both where it is being imported and where it is being used all at the same time.  Yes, I prefer to used the 'named' import.