JSFiddle - React, Tailwind, and code Playground

JavaScript

//Let's create a function
function test(){
console.log("I am a test function");    
}

var x=function(){
 console.log("I am an anonymous function");   
}

//Testing the "this" context
function whatisThis(){
 console.log(this);   
}
var obj={
    test:function(){console.log(this);}
};

var y=new whatisThis();
y.test=obj.test;
test(); //Normal Function Call
x(); //Anonymous Function Call they can be unamed
whatisThis(); //this is Global Object
obj.test(); //Refers to the Obj
y.test(); //this changes to the Whatisthis Object because we used the "new"
//Let's Play with the this
//Global Variable
w=[2,4,5,6]; // an array in the Global Object
var objectArray={w:[4,3,4,3,4,3]}; //an Array in an Object called objectArray
/*The function uses the this.w to refer to the array however if we intend to access the objectarray.w we need to change the context in which we want to use, by default this in a function refers to the Global Object "Window" which jquery/dojo and other frameworks sits on, to shift the context we need to use
the apply since w plan to take an a large number of arguments */ 
function countArray(){
console.log("There are %d items",this.w.length);
}
countArray(w);
countArray.apply(objectArray);