последний элемент





js/script.js
  • var ara = [1, 2, 3, 4, 5];
  •  
  • function funMake() {
  •  document.write(ara[ara.length-1] + '&nbsp');
  • }
var ara = [1, 2, 3, 4, 5];

function funMake() {
 document.write(ara[ara.length-1] + ' ');
}


index.html
  • <!DOCTYPE html>
  • <html>
  • <head>
  •  <meta charset="utf-8" />
  •  <title>New Page</title>
  •  <script src="js/script.js"></script>
  • </head>
  • <body>
  • <script>
  •  funMake();
  • </script>
  • </body>
  • </html>
  • <!DOCTYPE html>
  • <html>
  • <head>
  •  <meta charset="utf-8" />
  •  <title>New Page</title>
  •  <script src="js/script.js"></script>
  • </head>
  • <body>
  • <script>
  •  funMake();
  • </script>
  • </body>
  • </html>