JavaScript Array unshift()

The JavaScript array unshift() method is used to add one or more elements at the starting index of the given array.

Syntax:

array.unshift (element1,element2,....)

Parameters: element1,element2,… : The elements to be added in a given array.

Returns: Original array with specific addition elements.

Example:

<!DOCTYPE html>
<html>
<body>
<script>
var a = ["GOLD","SILVER","DIAMOND","RUBY","PLATINUM"]
var result=a.unshift("BRONZE");
document.writeln(a);
</script>
</body>
</html>
Please follow and like us:
Content Protection by DMCA.com