Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commite7ee3d8

Browse files
authored
Add files via upload
1 parent54481ee commite7ee3d8

11 files changed

+110
-0
lines changed

‎accidental-global.js‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
functionfoo(){
2+
lety=x=0;// window object
3+
x++;
4+
y++;
5+
returnx;
6+
}
7+
8+
console.log(foo(),typeofx,typeofy);

‎class-multiple-constructors.js‎

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
classRectangle{
2+
constructor(height,width){
3+
this.height=height;
4+
this.width=width;
5+
}
6+
7+
constructor(width){
8+
this.width=width;
9+
}
10+
// Getter
11+
getarea(){
12+
returnthis.calcArea();
13+
}
14+
// Method
15+
calcArea(){
16+
returnthis.height*this.width;
17+
}
18+
}
19+
20+
constsquare=newRectangle(20,30);
21+
22+
console.log(square.area);// 600

‎eventloop-order.js‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
functionmain(){
2+
console.log('A');
3+
setTimeout(
4+
functionprint(){console.log('B');}
5+
,0);
6+
console.log('C');
7+
}
8+
main();// A,C and B

‎floatingpoint-problem.js‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
console.log(0.1+0.2===0.3);

‎function-arrow-context.js‎

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
functionUser(name,age){
2+
this.name=name;
3+
this.age=age;
4+
5+
this.getProfile=function(){
6+
// Outer function context
7+
console.log(this.constructor.name);// User
8+
return()=>{
9+
// Inner function context
10+
console.log(this.constructor.name);// User(Get it from the outer context)
11+
console.log("I'm "+this.name+", "+this.age+" yrs old");
12+
};
13+
}
14+
}
15+
16+
letuser=newUser('John',25);
17+
letprofile=user.getProfile();
18+
profile();//I'm John, 25 yrs old

‎function-context.js‎

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
functionUser(name,age){
2+
this.name=name;
3+
this.age=age;
4+
5+
this.getProfile=function(){
6+
// Outer function context
7+
console.log(this.constructor.name);// User
8+
returnfunction(){
9+
// Inner function context
10+
console.log(this.constructor.name);// Window
11+
console.log("I'm "+this.name+", "+this.age+" yrs old");
12+
};
13+
}
14+
}
15+
16+
varuser=newUser('John',25);
17+
varprofile=user.getProfile();
18+
profile();//I'm undefined, undefined yrs old

‎function-expression.js‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
vary=1;
2+
3+
console.log(y);
4+
if(functionf(){}){
5+
y+=typeoff;
6+
console.log(y);
7+
}
8+
console.log(y);

‎function-hoisted.js‎

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
letobj=['love','blue',1016,'india']
2+
varcar=Vehicle.apply({},obj);
3+
console.log(car);
4+
5+
functionVehicle(model,color,year,country){
6+
this.model=model;
7+
this.color=color;
8+
this.year=year;
9+
this.country=country;
10+
returnthis
11+
}

‎function-without-new.js‎

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
functionVehicle(model,color,year,country){
2+
this.model=model;
3+
this.color=color;
4+
this.year=year;
5+
this.country=country;
6+
}
7+
8+
varcar=newVehicle("Honda","white","2010","UK");
9+
console.log(car);

‎functiontest.js‎

Whitespace-only changes.

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp