JSFiddle - React, Tailwind, and code Playground
by Artem
JavaScript
'use strict';
var Animal = function(name) {
var _legs = 4;
this.name = name;
this.hasLegs = function() {
return `${this.name} has ${_legs} legs.`;
};
};
Animal.prototype = Object.create(null);
Animal.prototype.toString = function() {
return this.name || undefined;
};
Animal.prototype.speak = function() {
return this.name + ' can speak.';
};
var Dog = function(name) {
Animal.call(this, name);
this.nnn = 'ss';
};
Dog.prototype = Animal.prototype;
Dog.prototype.constructor = Dog;
var aban = new Dog('Aban');
delete aban.constructor.prototype.speak;
/* console.log */ //console.log(aban.hasLegs());
var Person = (function() {
var _bye = function(){
return 'bye';
};
return {
constructor: function(name, age) {
this.name = name;
this.age = age;
return this;
},
greet: function() {
return 'Hello, ' + this.name;
},
bye: _bye
}
})();
var john = Object.create(Person).constructor('John', 25);
/* console.log */ //console.log(john);
var Wolf = function(){
this.name = 'Волк';
};
Wolf.toString = function(){
return 'gffg';
};
var GreyWolf = function(){
this.color = 'Серый';
};
GreyWolf.prototype = new Wolf();
GreyWolf.prototype.constructor = GreyWolf;
var wolfy = new GreyWolf();
//delete wolfy.constructor.prototype.name;
//delete Object.getPrototypeOf(wolfy).name;
/* console.log */ //console.log(wolfy);
/*for(let p in wolfy){
if(wolfy.hasOwnProperty(p))
console.log(wolfy[p]);
}
*/
var Grey = {
color: 'Серый'
};
var wolfyy = Object.create(Grey);
console.log(Grey.hasOwnProperty('color'));