23
loading...
This website collects cookies to deliver better user experience
let x = 1;
if(x){
x = 10;
}
// Output: x = 10
let x = 1;
x &&= 10
// Output: x = 10
let x = 0;
x = x || 10;
// Output: x = 10
let x = 0;
x ||= 10
// Output: x = 10
let x;
let y = 10;
x ??= y;
// A billion dollar that I want to earn
const money = 1_000_000_000;
const money = 1_000_000_000.00;
// Also can be used for Binary, Hex, Octal bases
const s = "You are reading JavaScript 2021 new updates.";
console.log(s.replaceAll("JavaScript", "ECMAScript"));
// output : You are reading ECMAScript 2021 new updates.
const promiseOne = new Promise((resolve, reject) => {
setTimeout(() => reject(), 1000);
});
const promiseTwo = new Promise((resolve, reject) => {
setTimeout(() => reject(), 2000);
});
const promiseThree = new Promise((resolve, reject) => {
setTimeout(() => reject(), 3000);
});
try {
const first = await Promise.any([
promiseOne, promiseTwo, promiseThree
]);
// If any of the promises was satisfied.
} catch (error) {
console.log(error);
// AggregateError: If all promises were rejected
}
class Me{
showMe() {
console.log("I am a programmer")
}
#notShowMe() {
console.log("Hidden information")
}
}
const me = new Me()
me.showMe()
me.notShowMe()
//error
class Me {
showMe() {
console.log("I am a programmer");
}
#notShowMe() {
console.log("Hidden information");
}
showAll() {
this.showMe()
this.#notShowMe();
}
}
const me = new Me();
me.showAll();
//I am a programmer
//Hidden information
class Me {
get #Name() {
return "Animesh"
}
get viewName() {
return this.#Name
}
}
let name = new Me();
console.log(name.viewName)
// Output: Animesh