CHALLENGE
function trickyFunction() {
var x = 10;
if (x > 5) {
let y = x * 2;
x = y;
}
return x;
}
console.log(trickyFunction());
π11β€5
π31π€£20β€2π€1
This is an ever-evolving, very opinionated architecture and dev environment for new node projects using NestJS.
NarHakobyan
Please open Telegram to view this post
VIEW IN TELEGRAM
π9β€3π₯1
CHALLENGE
function trickyFunction() {
var obj = { a: 1 };
var anotherObj = obj;
obj.a = 2;
obj = { a: 3 };
anotherObj.a = 4;
return obj.a + anotherObj.a;
}
console.log(trickyFunction());
β€12π€6π2
π₯27π9β€5π€2
CHALLENGE
async function fetchData() {
let data = 'initial';
const promise = new Promise((resolve) => {
setTimeout(() => {
resolve('fetched');
}, 1000);
});
promise.then((result) => {
data = result;
});
return data;
}
fetchData().then(console.log);
π13β€2
π€16π14π€£11β€2π₯2
Please open Telegram to view this post
VIEW IN TELEGRAM
π€£75π€13π€©2
CHALLENGE
const WM = new WeakMap();
let obj = {};
let anotherObj = {};
WM.set(obj, 'object data');
WM.set(anotherObj, 'another object data');
obj = null;
// Let's check what's logged
console.log(WM.has(obj));
console.log(WM.has(anotherObj));
π9β€1
β€7π6π₯4
CHALLENGE
const mySet = new Set();
mySet.add(10);
mySet.add(20);
mySet.add(10);
mySet.add(30);
console.log(mySet.size);
π13
π€29π€£22π15β€10π€©1
CHALLENGE
function* customGenerator() {
yield 'Hello';
yield 'World';
return 'Done';
}
const gen = customGenerator();
console.log(gen.next().value);
console.log(gen.next().value);
console.log(gen.next().value);
π7β€1
What is the output?
Anonymous Quiz
22%
Hello, World, undefined
61%
Hello, World, Done
13%
Hello, World, undefined
5%
Hello, undefined, undefined
π14π€£14β€8
CHALLENGE
const myObject = {
a: 1,
b: 2,
c: 3,
[Symbol.iterator]: function* () {
for (let key of Object.keys(this)) {
yield this[key];
}
}
};
const iter = myObject[Symbol.iterator]();
console.log(iter.next().value);
console.log(iter.next().value);
console.log(iter.next().value);
β€3π3π€©1
What is the output?
Anonymous Quiz
65%
1 2 3
13%
1 1 1
11%
2 3 undefined
10%
undefined undefined undefined
β€12π€£10
Itβs time to fully wave goodbye to 2024, but not before Michael Rambeauβs annual analysis of which JavaScript projects fared best on GitHub over the past year. Even if you dislike GitHub stars as a metric for anything, this remains a great way to get a feel for the JavaScript ecosystem and see what libraries and tools have mindshare in a variety of niches. A fantastic roundup as always.
Michael Rambeau
Please open Telegram to view this post
VIEW IN TELEGRAM
π10β€2π₯2
CHALLENGE
var obj = { a: 10, b: 20 };
with (obj) {
var result = a + b;
}
console.log(result);
π4β€1
π€£23π7π€7β€4π₯2
An email parsing library happy in most JS runtimes. Takes the raw source of emails and parses them into their constituent parts.
Postal Systems
Please open Telegram to view this post
VIEW IN TELEGRAM
π7β€2π₯1