How to get first and last value from array in JS?

Small guide on arrays for a JavaScript beginner developer
27 October 2017   3118

For example, you have an array

var arr = ["A", "B", "C"];

and you need to get something like this:

var arr = ["A", "C"];

You can simply use this:

arr.splice( 1, arr.length - 2 );

Demo code:

var arr = ["A", "B", "C"];

arr.splice(1, arr.length - 2);


Splice takes at least 2 variables (this goes only if you use splice to remove items), the first being the position of the string at which you want to start removing items, and the second the number of items you actually want to remove.

After the first element of the array, remove the next X items with X being the length of the array minus the first and the last element (this is why you have the "-2").

Node.js v12.0.0 to be Rolled Out

It has giant list of updates, improvements and changes
24 April 2019   498

The release of Node.js 12.0.0, a platform for executing network applications in JavaScript, is available. Node.js 12.0 refers to branches with a long period of support, but this status will be assigned only in October, after stabilization. Updates for LTS branches are issued for 3 years. Support for the last LTS branch of Node.js 10.0 will last until April 2021, and the year before last LTS-branch 8.0 until January 2020. Support for the intermediate branch Node.js 11.0 will be discontinued in June 2019. The lifetime of the LTS branch 6.0 will end on April 30.

These are some of the large list of updates and new staff:

  • V8 engine was updated to version 7.4 with support for asynchronous stack traces, increasing await performance, parsing JavaScript and calls when the actual and declared number of arguments does not match;
  • TLS 1.3 is now¬†supported in the tls module and TLS 1.0 / 1.1 is shutdown by default;
  • Enhancing protection and checks on the size of allocated memory in the Buffer class;

Get more info at official website.