CHALLENGE
function createCounter() {
let count = 0;
return function(increment = 1) {
count += increment;
return count;
};
}
const counter1 = createCounter();
const counter2 = createCounter();
console.log(counter1());
console.log(counter1(5));
console.log(counter2(3));
console.log(counter1());
console.log(counter2());❤4👍1🔥1
🔥11👍2
Please open Telegram to view this post
VIEW IN TELEGRAM
❤3
👍7❤3🔥2
Please open Telegram to view this post
VIEW IN TELEGRAM
❤9🤔4👍1
Your favourite framework/lib of the year
Anonymous Poll
65%
React 🔵
9%
Angular 📸
4%
Svelte 🟠
9%
Vue.js 🌲
12%
Next.js
🤣10❤6👍1
Happy New Year! 🎄 🍾
Wishing you fewer meetings, more merges, and no Friday deploys.😆
@JavaScript Telegram Newsletter Team
Wishing you fewer meetings, more merges, and no Friday deploys.
@JavaScript Telegram Newsletter Team
Please open Telegram to view this post
VIEW IN TELEGRAM
❤33👍6🔥4
CHALLENGE
class Vehicle {
#engine = 'V6';
static count = 0;
constructor(type) {
this.type = type;
Vehicle.count++;
}
static getCount() {
return this.count;
}
get info() {
return `${this.type} with ${this.#engine}`;
}
}
class Car extends Vehicle {
static count = 0;
constructor(brand) {
super('car');
this.brand = brand;
Car.count++;
}
}
const tesla = new Car('Tesla');
const ford = new Car('Ford');
console.log(Vehicle.getCount());
console.log(Car.getCount());
console.log(tesla.info);❤3👍2🔥1
What is the output?
Anonymous Quiz
18%
2 0 car with V6
40%
2 2 Tesla with V6
22%
0 2 car with V6
19%
2 2 car with V6
❤8👍2
CHALLENGE
async function fetchData() {
return Promise.resolve('data');
}
async function processData() {
console.log('start');
const result = fetchData();
console.log(typeof result);
const data = await fetchData();
console.log(typeof data);
console.log('end');
}
processData();❤8
What is the output?
Anonymous Quiz
43%
start object string end
32%
start object data end
15%
start string object end
11%
start function string end
❤6🤔3🤣2
CHALLENGE
function* fibonacci() {
let a = 0, b = 1;
yield a;
yield b;
while (true) {
let next = a + b;
yield next;
a = b;
b = next;
}
}
const gen = fibonacci();
const results = [];
for (let i = 0; i < 6; i++) {
results.push(gen.next().value);
}
console.log(results.join(','));❤4👍1🤔1
❤3🤔3👍1🔥1
CHALLENGE
const user = {
name: 'Sarah',
age: 28,
getName() {
return this.name;
}
};
const { getName } = user;
const boundGetName = user.getName.bind(user);
console.log(getName());
console.log(boundGetName());
console.log(user.getName());❤5🤔2
What is the output?
Anonymous Quiz
23%
undefined undefined Sarah
39%
undefined Sarah Sarah
12%
TypeError Sarah Sarah
26%
Sarah Sarah Sarah
👍8❤1🤔1
CHALLENGE
function* outer() {
yield 1;
yield* inner();
yield 4;
}
function* inner() {
yield 2;
yield 3;
}
const gen = outer();
console.log(gen.next().value);
console.log(gen.next().value);
console.log(gen.next().value);
console.log(gen.next().value);🔥3❤1👍1
What is the output?
Anonymous Quiz
23%
1 undefined undefined 4
46%
1 2 3 4
21%
1 [object Generator] 4 undefined
10%
1 2 3 undefined
❤3🤔3🤩1
CHALLENGE
const obj = { a: 1, b: 2, c: 3 };
const entries = Object.entries(obj);
const keys = Object.keys(obj);
const values = Object.values(obj);
const result = {
entriesLength: entries.length,
keysJoined: keys.join('-'),
valuesSum: values.reduce((sum, val) => sum + val, 0),
firstEntry: entries[0]
};
console.log(result.entriesLength);
console.log(result.keysJoined);
console.log(result.valuesSum);
console.log(result.firstEntry);❤1🔥1
What is the output?
Anonymous Quiz
18%
3 a,b,c 6 [ 'a', 1 ]
35%
3 a-b-c 6 [ 'a', 1 ]
37%
3 'a-b-c' 6 [ 'a', 1 ]
10%
3 a-b-c 6 ['a', 1]
👍8🤔4❤3🤣2🔥1
At the start of each year, Michael rounds up the projects in the JavaScript ecosystem that gained the most popularity on GitHub in the prior year. After a two-year run of topping the chart, shadcn/ui has been pushed down to #3 by n8n and React Bits. This is a fantastic roundup, now in its tenth(!) year, and features commentary from a few industry experts too.
Michael Rambeau et al.
Please open Telegram to view this post
VIEW IN TELEGRAM
❤6👍3🔥3