JSFiddle - React, Tailwind, and code Playground

by shravan

JavaScript

var print = function(number, context) {
    console.log(context + " - " + number + " : "  + this.firstName + " " + this.lastName);
};

var person1 = { 
    firstName : "Shravan Kumar",
    lastName : "Kasagoni",
    printName : print
};

var person2 = { 
    firstName : "Pranav",
    lastName : "Ainavolu",
    printName : print
};

var firstName = "My First Name",
    lastName = "My Last Name";

person1.printName(1);
person2.printName(2);

print(3); //error because of jsfiddle

print.apply(person1, [1, "person1"]);
print.apply(person2, [2, "person2"]);
print.apply(this, [3,"global"]); //error because of jsfiddle