JSFiddle - React, Tailwind, and code Playground
by alr3
JavaScript
function Being () {
this.living = true;
var privateMethod = function() {
console.log('Called Being:Private');
};
privateMethod();
var simpl = "Simple";
console.log(simpl);
function doSomething() {
console.log('I\'m doing something');
}
this.breathes = function() {
console.log('breaths:Being');
}
this.callPriv = function() {
this.privateMethod.call(this);
}
this.onlyOnCls = function() {
console.log('Only on Cls');
}
}
Being.prototype.breathes = function () {
console.log('breathes:Being.prototype');
return true;
};
Being.prototype.callPrivate = function() {
this.privateMethod();
};
ChildClass.prototype = new Being();
function ChildClass () {
this.blogs = true;
this.living = false;
//this.onlyOnCls = function() {
// console.log('in child')
//}
}
ChildClass.prototype.anotherFunc = function () {
console.log('ChildClass:prototype.anotherfunc');
};
//ChildClass.prototype.onlyOnCls = function() {
// console.log('in child:p')
//}
function sayHello2(name) {
var text = 'Hello ' + name; // local variable
var sayAlert = function() { console.log(text); }
return sayAlert;
}
var helloClose = sayHello2('yo');
helloClose();
var t1 = new Being();
console.log(t1.living);
t1.breathes();
console.log(t1.simpl);
//t1.doSomething();
//t1.callPriv();
var t2 = new ChildClass();
t2.breathes();
t2.onlyOnCls();
console.log(t2.blogs);
console.log(t2.living);