JSFiddle - React, Tailwind, and code Playground

by somya_kashyap3

JavaScript

// "0" ==  1

/*
var a = "1";

if(a.valueOf()){
console.log("hi");
}
*/
var k = "Harvard";
function myFunc(k){
    console.log("this is the function parameter k: "+k);
  k = "Yale";
    console.log("this is still the function parameter k: "+k);
}
myFunc(k);
console.log("When we're done, the global k is: "+k);
console.log("This is the same as: "+window.k);

var a = [{me : "somya", id : 41119949, age : 59}, 1, 3, "hi"];
for(var i = 0; i < a.length; i++){
	console.log(a[i]);
}

function n(name, age)  {
	this.name = name;
  this.age = age;
  this.toString = function a(){
  console.log(this.name);
  
  };
}

var b = new n("cicy", 45);
console.log(b.name);
console.log(b.toString());
console.log(b.hasOwnProperty('valueOf'));

if (typeof String.prototype.trim == "undefined")
{ String.prototype.trim = function() { return this.replace(/^\s+|\s+$/g,''); }; }

c = {
	fname : "ashi",
  lname : "boyance"
}
c.address = "51 battle street";

console.log(c.address);

function Container(param) {

		this.member = param;
    var secret = 3;
    var that = this;

    function dec() {
        if (secret > 0) {
            secret -= 1;
            return true;
        } else {
            return false;
        }
    }
    
    this.a = function(){
    	return secret+2;
    }


    this.service = function () {
        return dec() ? that.member : null;
    };
}
 var ash = new Container("hi");
 console.log(ash.a());