JSFiddle - React, Tailwind, and code Playground

by Nilesh Injulkar

HTML

<script src="https://getfirebug.com/firebug-lite-debug.js"></script>

JavaScript

/******************************************/
console.log('console testing.');
a = 5;
var b = null;

/******************************************/
functionDeclaration();
//Uncaught ReferenceError: functionExpression is not defined 
//functionExpression(); 

function functionDeclaration(){
    console.log('from function declaration');
}

functionExpression = function(){
    console.log('from function expression');
}

functionDeclaration();
functionExpression(); 
console.log('functionDeclaration.name =', functionDeclaration.name);
console.log('functionExpression.name =',  functionExpression.name);

/*****************************************************/
//Uncaught ReferenceError: function1 is not defined 
//function1();
//Uncaught ReferenceError: function2 is not defined 
//function2();

function1 = function function2(){
    console.log('from function1 = function function2');   
    //function1 visible here
    //function2 visible here
}
//console.log(function1 === function2); 
function1();
//Uncaught ReferenceError: function2 is not defined 
//function2();

/***********Javascript has no classes********/
/***********In Javascript everything is object********/

var person1 = {
    firstName : 'Nilesh',
    lastName : 'Injulkar',
    age : 23,
    greet : function(greeting){
        //this is required to access properties eg. firstName
        var temp = null;
        console.log(greeting, this.firstName, this.lastName);
    }
}
console.log(person1.firstName);
person1.greet('Namaste');

var person2 = new Object();
person2.firstName = 'Nilesh';
person2.lastName = 'Injulkar';
person2.age = 23;
person2.greet = function(greeting){
    //requires this
    console.log(greeting, this.firstName, this.lastName);
}
console.log(person2.firstName);
person2.greet('Shubhprabhat');

//Object constructor
//using function inside
function Person(firstName, lastName, age){
    this.firstName = firstName;
    this.lastName = lastName;
    this.age = age;
    //greet method gets recreated...