24 Array methods but in this example only 23
Last is map method which is covered separately.
var a=["Gaurav","Aditya", "Himanshu", "Divyansh"];
var b=["Sanjay","Aman"];
var c=["neha","mahima"];
function checkadult(age){
return age>=18;
}
document.write(a+"<--normal<br>");
a.sort();
document.write(a+"<--sort()<br>");
a.reverse();
document.write(a+"<--reverse()<br>");
a.pop();
document.write(a+"<--pop()<br>");
a.push("Rahul");
document.write(a+"<--push()<br>");
a.shift();
document.write(a+"<--shift()<br>");
a.unshift("Ajay");
document.write(a+"<--unshift()<br>");
var ar=a.concat("Sonu");
document.write(ar+"<--concat()<br>");
var arr=ar.concat(b);
document.write(arr+"<--concat()<br>");
var arrr=ar.concat(b,c);
document.write(arrr+"<--concat()<br>");
var join=arr.join("/");
document.write(join+"<--join()<br>");
var slice=arrr.slice(1,3);
document.write(slice+"<--slice()<br>");
var slice=arrr.slice(3);
document.write(slice+"<--slice()<br>");
var slice=arrr.slice(-2);
document.write(slice+"<--slice()<br>");
var slice=arrr.slice(-5,-3);
document.write(slice+"<--slice()<br>");
slice.splice(1,0,"Gaurav", "charchit","Gaurav");
document.write(slice+"<--splice()<br>");
var check=Array.isArray(slice);
document.write(check+"<--isArray()<br>");
var index=slice.indexOf("Gaurav",2);
document.write(index+"<--indexOf()<br>");
var index=slice. lastIndexOf("Gaurav",2);
document.write(index+"<--lastIndexOf()<br>");
var includes = slice.includes("Gaurav");
document.write(includes+"<--includes()<br>");
var ages=[12,20,13,18];
document.write(ages+"<br>");
var b=ages.some(checkadult);
document.write(b+"<--some()<br>");
var b=ages.every(checkadult);
document.write(b+"<--every()<br>");
var b=ages.find(checkadult);
document.write(b+"<--find()<br>");
var b=ages.findIndex(checkadult);
document.write(b+"<--findIndex()<br>");
var b=ages.filter(checkadult);
document.write(b+"<--filter()<br>");
ages.toString();
document.write(ages+"<--toString()<br>");
document.write(ages.valueOf()+"<--valueOf()<br>");
ages.fill("Ram");
document.write(ages+"<--fill()<br>")
slice.forEach(loop);
function loop(value,index){
document.write(index+":"+value+"<--for Each()<br>")}
Output
Comments
Post a Comment