JAVASCRIPT push () adds the specified value to the array

JAVASCRIPT push () to add one or more elements to the end of the array, and returns the new length. It is directly modify the array, rather than creating a new array. push () and pop () after using an array of advanced features offered out.

<!DOCTYPE html>
<html>
<head>
    <Title> push () to add value to the specified array </ title>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
</head>
<body>
<script type="text/javascript">
    var arr = new Array(3)
    arr [0] = "Henan"
    arr [1] = "Hebei"
    arr [2] = "Jiangsu"
    document.write ( "original array elements:" + arr)
    document.write("<br />")
    document.write ( "post-added element array length:" + arr.push ( "Jilin"))
    document.write("<br />")
    document.write ( "after the addition of numeric array:" + arr)
</script>
</body>
</html>

  

Guess you like

Origin www.cnblogs.com/rjbc/p/11666166.html