JSFiddle - React, Tailwind, and code Playground

by Erin Houston

JavaScript

window.name = 'windo';

function Taco(name) {
    this.name = name;
    var nameCool = name + ' cool';

    function PrintNameThis() {
        console.log(this.name);
    }
    this.showTheWindowScope = function() {
        PrintNameThis();
    };
    var variblePrintFunc = function() {
        console.log(this.name);
    };
    
    this.showVaribleFuncScope = function(){
        variblePrintFunc();        
    };
    
    this.showThisPrintFunc = function(){
        console.log(this.name);        
    };
    
    this.localScopePrint= function(){
        console.log(nameCool);        
    };
    return this;

}

Taco.prototype.protoLocPrintCall = function(){
    console.log(nameCool);
};

Taco.prototype.protoThisPrintCall = function(){
    console.log(this.name);
};

var tc = new Taco("food for thought");

tc.showTheWindowScope();
tc.showVaribleFuncScope();
tc.showThisPrintFunc();
tc.protoThisPrintCall ();
tc.localScopePrint();
tc.protoLocPrintCall();