خذا خوخ كود جافا سكربت
class Person{
constructor(name, age){
this.name =name;
this.age =age;
}
get age (){
return this._age;
}
hellow(){
console.log(
`Hello , My name is ${this.name} , and I am ${this.age} years old`
)
}
}
class Student extends Person {
constructor(name,age,level){
super(name ,age);
this.level =level;
}
}
const Person = new Person('Ibrahim',26);
Student.hellow();
// try and catch
try{
alert('try');
}catch (error){
alert('catch');
}
function area(width,height){
if(isNaN(width) || isNaN(height)){
throw Error('Parameter is a number');
}
return width *height;
}
const wait =time => new Promise(
(resolve,reject) =>{
if(time > 5000) reject('Sory I can \ t wait');
setTimeout(resolve ,time)
}
);
wait(2000)
.then(() => {console.log("hello");
return wait(1000);
})
.then(() => {
console.log('world !');
});
new Promise((resolve,reject) =>{
setTimeout(() => resolve(1), 1000);
})
.then(result => {
console.log(result);
return result *2;
});
حتى لو قمت بادخال اوامر بسيطه