Javascript tutorial - 16 - Array Methods 1
Dave Partner

Javascript tutorial - 16 - Array Methods 1

  • 0 Replies
  • 282 Views

0 Members and 1 Guest are viewing this topic.

*

Offline Dave Partner

  • Administrator
  • Full Member
  • *****
  • 116
    • View Profile
Javascript tutorial - 16 - Array Methods 1
« on: November 15, 2016, 03:34:26 AM »
&feature=youtu.be&hd=1

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


<body>
   <script type="text/javascript">
      //array methods
     
     
      //using object literal
      var ourNumbers = [2, 59, 659, 5524, "Dave", "Partner" ];
      //toString
      /*
       document.write(ourNumbers);
       document.write("<br/>");
       document.write(ourNumbers.toString());
       
       
        //join()
        document.write(ourNumbers.join(" - "));
        //output : 2 - 59 - 659 - 5524 - Dave - Partner
     
       
        //pop()
        //document.write(ourNumbers.pop());
        //output : Partner
       
        ourNumbers.pop();
        document.write(ourNumbers);
        //output : 2,59,659,5524,Dave
         
         
         //push()
         ourNumbers.push("Whatever");
        document.write(ourNumbers);
        //output: 2,59,659,5524,Dave,Partner,Whatever
       
       
       
        //shift() - pop() from the opposite direction
        ourNumbers.shift();
        document.write(ourNumbers);
         
         //unshift()
         ourNumbers.unshift("Anything");
         document.write(ourNumbers);
         
         
         //changing array elements
         ourNumbers[4] = "Ali";
         document.write(ourNumbers);
         
         
         //length
          document.write(ourNumbers.length);
         
         ourNumbers[ourNumbers.length] = "Davepartner.com";
         document.write(ourNumbers);
       
       
        //delete
        delete ourNumbers[4];
        document.write(ourNumbers);
        //output : 2,59,659,5524,,Partner
         
        ourNumbers[3] = undefined;
        ourNumbers[2] = null;
         document.write(ourNumbers);
         */
/*       
concat
every   
filer
forEach
join
indexOf
lastIndexOf
map
pop
push
reverse
shift
slice
some
sort
splice
toSource
toString
unshift
valueOf


*/
   </script>
</body>
</html>
« Last Edit: November 15, 2016, 04:02:20 AM by Dave Partner »