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...
Please Whitelist JSFiddle in your content blocker.
Help keep JSFiddle free for always by one of two ways:
Whitelist JSFiddle in your content blocker (two clicks)
Go PRO and get access to additional PRO features →
Join the 4+ million users, and keep the JSFiddle dream alive.
Ad-free
All ads in the editor and listing pages are turned completely off.
Use pre-released features
You get to try and use features (like the Palette Color Generator) months before everyone else.
Fiddle collections
Sort and categorize your Fiddles into multiple collections.
Private collections and fiddles
You can make as many Private Fiddles, and Private Collections as you wish!
Console
Debug your Fiddle with a minimal built-in JavaScript console.