JSFiddle - React, Tailwind, and code Playground

by Samar Pattanayak

JavaScript

class point {
  constructor(x, y) {
    this.x = x;
    this.y = y;
  }
  tostring() {
    console.log(`${this.x} telling ${this.y} ha hi ha`)
  }
}
point.prototype.property1="he he eh"
point.prototype.gh = function() {
  return "oh my god"
}
var pointobj = new point("Samar", "Varun")
console.log("inside parent")
pointobj.tostring();
console.log(Object.keys(pointobj))
console.log(Object.getOwnPropertyNames(pointobj))
console.log(Reflect.ownKeys(pointobj))
for(let i in pointobj){
	console.log(i)
}

console.log(Object.getPrototypeOf(pointobj))
console.log(pointobj.gh())




console.log(typeof point)

class subpoint extends point {
  constructor(x, y, color) {
    super(x, y);
    this.color = color;
  }
  tostringC() {
    super.tostring()
    console.log(`${this.x} telling ${this.y} color ${this.color}`)
  }
}
subpoint.prototype.one="hhhhh"
var subpointobj = new subpoint("Raghu", "Rajiv", "red")
console.log("****tostring of subpoint class*********")
subpointobj.tostringC()

console.log("****details of subpoint class*********")
console.log(Object.keys(subpointobj))
console.log(Object.getOwnPropertyNames(subpointobj))
console.log(Reflect.ownKeys(subpointobj))
for(let i in subpointobj){
	console.log(i)
}

console.log(Object.getPrototypeOf(subpointobj))

console.log("****Inside another class*****")
class Foo {
  constructor(prop) {
      this.prop = prop;
    }
    //static methods will not be available in prototype or 				
    //created object

  static staticMethod() {
    console.log('classy static ');
  }
  prototypeMethod() {
    console.log('classy prototypical ');

  }
}
const foo = new Foo(123);
console.log(Foo.prototype) //Foo should be a function or class not an object
console.log(Object.getPrototypeOf(foo)) //param should be an object. so Foo it will not work as its a function
console.log(Object.keys(foo))


//function add(){
//this.a=1,
//this.b=2
//}
//var addo=new...