if(1){
let circle={
center:{
x:1,
y:3
},
radius:10,
};
console.log(circle);
circle.show=function(){
console.log(this.center);
}
circle.show();
}
if(1){
let factory=function(){
let obj={};
obj.show=function(){
console.log("hello world");
}
return obj;
}
let new_obj=factory();
new_obj.show();
}
if(1){
let constructor=function(){
this.show=function(){
console.log("hello world");
}
}
let new_obj=new constructor();
new_obj.show();
}
if(1){
let circle=function(){
return {
show:function(){
console.log("hello world");
}
}
};
let new_obj=circle();
console.log(new_obj.constructor);
}
if(1){
let circle=function(){
return{
show:function(){
console.log("hello world");
}
}
};
let new_obj=circle();
console.log(new_obj);
new_obj.data="gaowanlu";
console.log(new_obj);
new_obj["id"]=1234;
console.log(new_obj);
delete new_obj["show"];
console.log(new_obj);
}
if(1){
let obj={
id:"gaowanlu",phone:"1234"
};
for(let i in obj){
console.log(obj[i]);
}
}
if(1){
let Circle=function(){
let data=0;
this.show=function(){
data+=1;
console.log(data);
}
};
let new_obj=new Circle();
new_obj.show();
new_obj.show();
new_obj.show();
}
if(1){
let Circle=function(){
let new_obj={};
Object.defineProperty(new_obj,"data",{
get:function(){
return "hello";
},
set:function(el){
console.log(el);
}
});
return new_obj;
};
let new_obj=Circle();
new_obj.data="qw";
console.log(new_obj.data);
}
if(1){
let Circle=function(radius){
this.radius=radius;
this.draw=function(){
console.log('draw');
};
}
let circle= new Circle(2);
console.log(circle.__proto__.__proto__);
}
if(1){
let person={name:"gaowanlu"};
Object.defineProperty(person,"name",{
writable:false,
enumerable:true,
configurable:false,
});
person.name="opp";
delete person.name;
console.log(person);
}
if(1){
let Circle=function(){
this.draw=function(){
console.log('draw');
}
};
let circle_1=new Circle();
let circle_2=new Circle();
let Car=function(){
this.money=1000000;
};
Car.prototype.draw=function(){
console.log("draw");
}
let car_1=new Car();
let car_2=new Car();
car_1.draw();
car_2.draw();
}
if(1){
let Cir=function(){
this.draw=function(){
console.log("draw");
}
}
Cir.prototype.move=function(){
console.log("move");
this.draw();
}
let new_obj=new Cir();
new_obj.move();
}
if(1){
let Cir=function(){
this.data=123;
};
Cir.prototype.name="gaowanlu";
let new_obj=new Cir();
console.log(Object.keys(new_obj));
for(let key in new_obj){
console.log(key);
}
console.log(new_obj.hasOwnProperty("data"));
console.log(new_obj.hasOwnProperty("name"));
}
if(1){
let Tesla=function(){
this.type="Tesla";
};
Tesla.prototype.show=function(){
console.log(this.type);
}
let Audi=function(){
this.type="Audi";
};
Audi.prototype.show=function(){
console.log(this.type);
}
let car_1=new Tesla();
let car_2=new Audi();
car_1.show();
car_2.show();
console.log(car_1);
console.log(car_2);
Tesla=function(){
this.type="tesla"
};
Tesla.prototype.show=function(){
console.log(this.type);
}
Audi=function(){
this.type="audi";
};
Audi.prototype=Object.create(Tesla.prototype);
Audi.prototype.constructor=Audi;
let nice_car=new Audi();
nice_car.show();
}
if(1){
let CarColor=function(color){
this.color=color;
}
let Tesla=function(color){
CarColor.call(this,color);
this.type="Tesla";
};
let car=new Tesla("red");
console.log(car);
}
if(1){
let extend=function(child,parent){
child.prototype=Object.create(parent.prototype);
child.prototype.constructor=child;
}
let CarColor=function(color){
this.color=color;
};
CarColor.prototype.ShowColor=function(){
console.log("red");
}
let Tesla=function(color){
CarColor.call(this,color);
this.type="tesla";
};
extend(Tesla,CarColor);
let my_car=new Tesla("blue");
my_car.ShowColor();
Tesla.prototype.ShowColor=function(){
console.log(this.color);
};
my_car=new Tesla("yellow");
my_car.ShowColor();
}
if(1){
let extend=function(child,parent){
child.prototype=Object.create(parent.prototype);
child.prototype.constructor=child;
};
let CarColor=function(){
this.color="red";
};
CarColor.prototype.ShowColor=function(){
console.log("red");
};
let Tesla=function(color){
this.type="tesla",
CarColor.call(this,color);
};
extend(Tesla,CarColor);
Tesla.prototype.ShowColor=function(){
console.log("blue tesla");
};
let Audi=function(color){
CarColor.call(this,color);
this.type="audi";
};
extend(Audi,CarColor);
Audi.prototype.ShowColor=function(){
console.log("black audi");
};
let array=[new Tesla(),new Audi()];
for(let car of array){
car.ShowColor();
}
}
if(1){
let Tesla=function(color){
this.color=color;
this.speed="299km/s";
this.type="tesla";
this.showUser=function(){
console.log("gaowanlu");
};
};
class Tesla_class{
constructor(color){
this.color=color;
this.speed="299km/s";
this.type="tesla";
}
showUser(){
console.log("gaowanlu");
}
}
let car = new Tesla_class("red");
console.log(car);
console.log(typeof(Tesla_class));
if(1){
class via{
}
const yiu=class{
}
}
let ff=class{
constructor(){
}
draw(){
}
static parse(){
}
};
ff.parse();
let obj=new ff();
const _draw=Symbol();
let lua=class{
constructor(){
}
[_draw](){
console.log("私有");
}
};
const _name=new WeakMap();
const _showname=new WeakMap();
let didi=class{
constructor(){
_name.set(this,123456);
_showname.set(this,function(){
console.log("_showname");
});
}
get radius(){
return 1;
}
set radius(el){
console.log(el);
}
}
}
if(1){
class TeslaColor{
constructor(color){
this.color=color;
}
ShowColor(){
console.log(this.color);
}
};
class TTCar extends TeslaColor{
constructor(color){
super(color);
}
}
}
if(1){
class GaoF{
move(){
console.log("GaoF");
}
}
class Fu extends GaoF{
move(){
}
}
}