Q:

Move multiple array elements from one array position to another

I need to move four items from an array of items to the first four positions.
Let say I have the below array:
var countryList=['Afghanistan','Albania', 'Argentina', 'Australia', 'Bangladesh', 'Belgium','Brazil',...]

I need to move Argentina, Australia, Belgium, and Brazil at first four positions. The modified array should look like:
var modifiedCountryList=['Argentina', 'Australia','Belgium', 'Brazil', 'Afghanistan', 'Albania', 'Bangladesh', ...]

I have found an answer here but it is for a single array element position move.
It seems like simple but I can not wrap my head around it.

A:

Make a new array with the output you expect. Also, I would suggest to use indexOf instead of includes as includes will give you error in IE browser. You can also make use of spread syntax ... that will add the array elements to your new array. 

const countryList1 = ['Afghanistan','Albania', 'Argentina', 'Australia', 'Bangladesh', 'Belgium','Brazil'];
const countriesInFirst = ['Argentina', 'Australia','Belgium', 'Brazil'];

const countryList2 = [
  ...countriesInFirst,
  ...countryList1.filter(country => countriesInFirst.indexOf(country) === -1)
];
console.log(countryList2);

includes() is not supported in IE browser. https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/includes#Browser_compatibility

