How to replace an item in an array

We may face this situation a lot in Javascript development. So the below is the simply solution to replace an item in an array with splice() method. // replace France to Italia var countries = ['USA', 'France', 'England']; countries.splice(1, 1, 'Italia'); console.log(countries); // ["USA", "Italia" »