Hola Chic@s 😃
ES12:
- Promise-any
const promise1 = new Promise((resolve, reject) => reject("reject"));
const promise2 = new Promise((resolve, reject) => resolve("resolve"));
const promise3 = new Promise((resolve, reject) => resolve("resolve2"));
Promise.any([promise1, promise2, promise3])
.then(response => console.log(response));
- Métodos privados
// declaracion de una clase
class User {};
// genera una instancia
//const newUser = new User ();
class user {
// metodos
greeting() {
return "hello";
}
};
const gndx = new user();
console.log(gndx.greeting());
const bebeloper = new user();
console.log(bebeloper.greeting());
// constructor
class user {
constructor() {
console.log("Nuevo usuario");
}
greeting() {
return "hello";
}
}
const david = new user();
// this
class user {
constructor(name) {
this.name = name;
}
// metodos
speak() {
return "Hello";
}
greeting() {
return `${this.speak()} ${this.name}`;
}
}
const ana = new user("Ana");
console.log(ana.greeting());
// setters getters
class user {
//constructor
constructor(name, age) {
this.name = name;
this.age = age
}
// metodos
#speak() {
return "Hello";
}
greeting() {
return `${this.speak()} ${this.name}`;
}
get #uAge() {
return this.age;
}
set #uAge(n) {
this.age = n;
}
}
const bebeloper1 = new user ("david", 15);
console.log(bebeloper1.uAge);
console.log(bebeloper1.uAge = 20);
¿Quieres ver más aportes, preguntas y respuestas de la comunidad?