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

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

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

AngularJS to Angular Migration Tools to be Released

New tools are called ngMigration Assistant and ngMigration Forum
17 August 2018   207

The JS-development team AngularJS has released two customers' "helper" - ngMigration Assistant and Forum. The tools show which migration from AngularJS to Angular is correct, how to simplify the process as much as possible and avoid mistakes.

ngMigration Assistant is a command-line tool that analyzes any AngularJS application, regardless of size, and recommends an optimal migration path. It provides statistics on the complexity, size, and patterns of an app. Based on this data, the program offers a list of clear recommendations that simplify the transition from AngularJS to Angular, taking into account the size and complexity of the code.

You can find an example of using the ngMigration Assistant for the AngularJS phone catalog application below. Using the ngma command, registered in the directory, analysis is performed and recommendations are written.

Displaying ngMigration Assitant statistics
Displaying ngMigration Assitant statistics

Initially, the tool shows statistics of the available data, and after - the stages of preparation for migration to Angular.

NgMigration Assitant Recommendations
NgMigration Assitant Recommendations

The new ngMigration Forum collects up-to-date information on migration paths and tools that provide the transition from AngularJS to Angular. ngMigration Forum is a place for sharing experiences, solving problems and asking questions.

The last update of Angular 6.1 was released in late July 2018. In Angular, support for TypeScript 2.8 and 2.9 was added, as well as the ability to configure the router to store and restore the scrolling position