About the application of call in js?

I briefly understand the use of call in js, which is used to change the direction of this. For example:

var fn1=function(){
    console.log(1);
}
var fn2=function(){
    console.log(2);
}
fn1.call(fn2);

fn2thisfn1,1.
elementsNodeList
var elements=document.querySelectorAll("div");
Array.prototype.forEach.call(elements,(element)=>{
     console.log(element)
});

callforEachcallback
callBackcallcall
Mar.15,2021

if you write it differently

Array.from(elements).forEach((element)=>{console.log(element)});

can you understand
NodeList is not js native Array, so it takes some strange tricks to use some of the methods in Array

Menu