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

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

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

Third Party Apps Could Read Twitter Messaging

According to the company, no one used this vulnerability and the issues is now solved
18 December 2018   575

Until the beginning of December, third-party applications could access Twitter private messages. According to the company, no one took advantage of this vulnerability. Terence Eden, who found it, was paid almost $ 3,000 under the Bug Bounty program.

In 2013, there was a leak of keys to the Twitter API - so applications could access the interface bypassing the social network. To protect users, Twitter implemented an application authorization mechanism through predefined addresses (Callback URL), but it didn’t suit everyone.

Applications that do not support Callback URLs could authenticate using PIN codes. With this authorization, a window pops up that lists which data the user opens to access. The window did not request access to private messages, but in fact the application received it.

On December 6, Twitter reported that it had solved the problem. Judging by the statement of the company on the HackerOne website, no one had time to take advantage of this vulnerability.

This is not the first social network security error related to the API. In September, Twitter discovered a bug in AAAPI (Account Activity API): the system sent a copy of the user's personal message to a random recipient.