function sayHello1() {
for (var i = 0; i < 5; i++) {
console.log(i);
}
console.log(i);
}
sayHello1();
function sayHello2() {
for (let i = 0; i < 5; i++) {
console.log(i);
}
console.log(i);
}
sayHello2();
const i = 1;
i = 2;
const person = {
name: 'Mosh',
walk: function () { },
talk() { }
};
person.talk();
person.name = 'John';
const targetMember = 'name';
person[targetMember] = 'John';
const person2 = {
name: 'John',
walk() {
console.log(this);
}
};
person2.walk();
const walk = person.walk;
console.log(walk);
walk();
const walk2 = person.walk.bind(person2);
walk2();
const square = function (number) {
return number * number;
};
const square2 = number => number * number;
console.log(square2(2));
const jobs = [
{ id: 1, isActive: true },
{ id: 2, isActive: true },
{ id: 3, isActive: false },
];
const activeJobs = jobs.filter(function (job) {
return job.isActive;
})
const activeJobs2 = jobs.filter((job) => job.isActive);
const person3 = {
talk() {
console.log('this', this);
}
};
person3.talk();
const person4 = {
talk() {
setTimeout(function () {
console.log('this', this);
}, 1000);
}
};
person4.talk();
const person5 = {
talk() {
setTimeout(
() => console.log('this', this),
1000);
}
};
person5.talk();
const colors = ['red', 'green', 'blue'];
colors.map((color) => '<li>' + color + '</li>');
colors.map(color => `<li>${color}</li>`);
const address = {
street: '',
city: '',
country: '',
};
const { street, city, country } = address;
console.log(street, city, country);
const { street: st } = address;
console.log(st);
const first = [1, 2, 3];
const second = [4, 5, 6];
const combined = first.concat(second);
const combined2 = [...first, 10, ...second];
const first_clone = [...first];
const first_prop = { name: 'Mosh' };
const second_prop = { job: 'Instructor' };
const props = { ...first_prop, ...second_prop, location: 'Australia' };
console.log(props);
const first_prop_clone = { ...first_prop };
class PPerson {
constructor(name) {
this.name = name;
}
walk() {
console.log("walk");
}
}
const person6 = new PPerson("John");
person6.walk();
class Teacher extends PPerson {
constructor(name, degree) {
super(name);
this.degree = degree;
}
teach() {
console.log("teach", this.degree);
}
}
const teacher = new Teacher("John", 1);
teacher.teach();
teacher.walk();
export class XXX { }
export const func = () => { };
import { Person } from "./person";
import { Teacher } from "./teacher";
export default class YYY { }