Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
  • Jquery .map() method

    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 549
    Comment on it

    Jquery .map( callback ) method is used to project the contents that is used in the array and then map this object with the new set of array, It is able to create a new array for calling every elements. It provides function once for each set of an array mapping the content with new array

    For example: If a user wishes to process a plain array or objects they can used the .map() function for traversing the whole set of array, This method is generally used for getting and setting the value of an array.

    Syntax for using the .map() function:- callback )

    Source Code:-

    <!DOCTYPE html>  
         <title>Jquery Arrays: Mapping an Array(square) </title>  
     <script src="//"></script>
       $(document).ready(function() {
        var numbers = [1, 2, 3, 4, 5, 6, 7];
          $("#display").text("The Original Numbers: " + numbers.join(","));
           // $.map() method with a function to project the contents of an array into a new array 
          numbers = $.map(numbers, function(i)  
         return i * i;
        $("#display2").text("Squared: " + numbers.join(", "));
         body{font-family:Verdana; color:#444;}
              <h3>Mapping of an Array(Square)</h3>
             <div id="display"></div>
      <div id="display2"></div>
       <button>Click Here</button><br>


    For seeing the result user can download file from the below link.


 0 Comment(s)

Sign In

Sign up using

Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: