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

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

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").

Frontend News Digest 12 - 18.10

Building command line spinners in Node.js, perfect architecure for your next node project and Zero update in this issue Frontend News Digest
18 October 2019   131

Greetings! I hope your week went great! Here's new Frontend news digest.

Another version of a super popular Node.js relaesed, get the info bellow! Also, you will be able learn about Firefox new websocket inspector, WordPress update and watch the video how to built classic layout fast in CSS grid


  • Build Command-Line Spinners in Node.js

CLI spinners creating will improve your Node.js terminal skills


  • Improving Form Controls in Microsoft Edge and Chromium 

The Chrome and Edge teams worked together on refreshing form controls in Chromium-based browsers; learn what they have made

  • Firefox’s New WebSocket Inspector

Overview of new Firefox's websocket inspector, which is going to be released in Firefox 71 but availbale only in Firefox Developer Edition at the moment.

  • The Perfect Architecture Flow for Your Next Node Project 

Best practices and architectural tips for your next Node project

  • Coloring Your Terminal Using Nodejs

Article on how coloring libraries like Chalk work under the hood.


  • WordPress 5.2.4 Release Addresses Several Security Issues

Information about security fixes the news WordPress release

  • Node v12.12.0 (Current)

Another update of the the popular JS RTE with some interesting changes, such as a --force-context-aware flag has been added to prevent addons that aren’t context aware from being loaded, the fs module has added opendir() and fs.Dir as ways to asynchronously iterate through directories and JSON module support has also been made experimental again, due to security concerns in the Web-based implementation of the idea.

  • Zero

A graphics pipeline implemented in JavaScript and rendered to the terminal that can run without GPU required.


Build a Classic Layout FAST in CSS Grid


  • Jen Simmons on Browser Features 

Discussion between Jen Simmons, designer advocate at Mozilla and two hosts, Dave Rupert and Chris Coyier. about how new features get shipped to browsers, and how you can get your ideas over to browser makers for consideration.