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.

No comments:

Post a Comment