JavaScript program for map function

 var ary=[11,4,9,16];

var b=ary.map(test);

function test(x){

    return x*10;

}

document. write(b);

var arr=[

{fname:"Yahoo",lname:"Baba"},

{fname:"Rahul",lname:"Kumar"},

{fname:"Karan",lname:"Sharma"}

];

document. write("<br>")

var c=arr.map(tests);

function tests(x){

    return x.fname;

}

document. write(c);


Output




Comments