Dave Partner

Javascript tutorial - 17 - Array Methods 2

  • 0 Replies
  • 196 Views

0 Members and 1 Guest are viewing this topic.

*

Offline Dave Partner

  • Administrator
  • Full Member
  • *****
  • 109
    • View Profile
Javascript tutorial - 17 - Array Methods 2
« on: November 15, 2016, 04:01:33 AM »




<!DOCTYPE html>
<html>
<head>
   
</head>


<body>
   <script type="text/javascript">
      //array methods 2
      
      
      //using object literal
      var ourNumbers = [2, 659, 59, 5524, "Partner" , "Dave"];
      var carBrands = ["Volvo", "Ferrari", "Trumpri", "Hilari", "Toyota"];
      var carBrands2 = ["Volvo", "Ferrari", "Trumpri", "Hilari", "Toyota"];
      //toString
      
        /*
        //splice
       ourNumbers.splice(1,2);
        document.write(ourNumbers);
        //output: 2,5524,Dave,Partner
        
      
        //concat()
        var totalArray = ourNumbers.concat(carBrands,carBrands2);
        document.write(totalArray);
          
        //slice
        var thirdArray = carBrands.slice(2,4);
        document.write(thirdArray);
        
        
        
        //sort()
        //document.write(ourNumbers.sort());
        document.write(ourNumbers.reverse()); */
/*        
concat
every   
filer
forEach
join
indexOf
lastIndexOf
map
pop
push
reverse
shift
slice
some
sort
splice
toSource
toString
unshift
valueOf


*/
   </script>
</body>
</html>