Skip to content

Commit 3527755

Browse files
authored
Update js codes.docx
1 parent a5fecb1 commit 3527755

1 file changed

Lines changed: 33 additions & 1 deletion

File tree

‎js codes.docx‎

Lines changed: 33 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2676,4 +2676,36 @@ printDetail.call(userDetails2, "India");
26762676
printDetail.apply(userDetails2, ["India"]);
26772677
let bindfunc= printDetail.bind(userDetails2, "India"); //creating a copy and invoke whenever require //don't call the diectly here like call function
26782678
bindfunc();
2679-
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
2679+
========================================================================================================================================================================
2680+
Foreach:
2681+
const Data=[
2682+
{name:"Google", category:"Product Based"},
2683+
{name:"Accenture", category:"service Based"},
2684+
{name:"Amazon", category:"Product Based"}
2685+
];
2686+
2687+
for(let i=0; i<Data.length; i++){
2688+
console.log(Data[i])
2689+
}
2690+
2691+
//foreach is HOF which take callback
2692+
Data.forEach((item)=>{ console.log(item) })
2693+
=====================================================================================================================================================================
2694+
Filter:
2695+
const Age=[1,2,3,4,5,6,7,8,9,0]
2696+
for(var i=0;i<Age.length;i++){
2697+
if(Age[i]>5){
2698+
console.log(Age[i])
2699+
}
2700+
}
2701+
2702+
const UpdatedAge= Age.filter(function(item){
2703+
if(item>5){
2704+
return true;
2705+
}
2706+
})
2707+
console.log(UpdatedAge)
2708+
2709+
const UpdatedAge= Age.filter((item)=>(item>5))
2710+
console.log(UpdatedAge)
2711+
=====================================================================================================================================================================

0 commit comments

Comments
 (0)