JSFiddle - React, Tailwind, and code Playground

by khurramali51

HTML

var Sequence = (function sequenceIIFE() { </br>
    
    // Private variable to store current counter value.  </br>
    var current = 0;  </br>
    
    // Object that's returned from the IIFE. </br>
    return {                                  </br>
        getCurrentValue: function() {  </br>
            return current;          </br>
        },            </br>
        
        getNextValue: function() {        </br>
            current = current + 1;    </br>
            return current;        </br>
        }              </br>
    };              </br>
      </br>
}());</br>

<h1> Arrow Function </h1>
<p>
 they have no binding of this. Instead, this is bound lexically. Simply put, this means that this will keep its meaning from its original context.
</p>
https://stackoverflow.com/questions/34361379/arrow-function-vs-function-declaration-expressions-are-they-equivalent-exch
https://codeburst.io/javascript-learn-understand-arrow-functions-fe2083533946

JavaScript

function createObject() {
  console.log('Inside `createObject`:', this.foo);
  return {
    foo: 42,
    bar: function() {
      console.log('Inside `bar`:', this.foo);
    },
  };
}


// 1st variation of IIFE function

!function(){
 alert("1st variation,");
 alert("you can use !~& any unary operator or void keyword");
 alert("the sign said its not a function but expression");

}();

//2nd Variation of IIFE function 
(function(){
 alert("this is the 2nd Variation");
})();

//returning a variale that can assign to variable 
var myValue = (function(){
    return "this is returned";
}());
alert(myValue);

var jO = (function(){
  return {
     var1 : 23,
     var2 : function(){
         return "testing";
     }
  };
}());

alert(jO.var1);
alert(jO.var2());


//arrow function    (parameters) => {statment}
// if no parameters   then      () => {statment}
// if only one parameter   then     paramter => {statment}
//if expression return then      () => statment  // we will remove braces
//                          or    parameter => statment
const add2 = (a,b) => {alert (a+""+b);};
add2(2,3);