CHALLENGE
function trickyFunction() {
var a = 10;
var b = a;
b = 15;
const obj1 = { x: 1 };
const obj2 = obj1;
obj2.x = 5;
console.log(a + ' ' + b + ' ' + obj1.x);
}
trickyFunction();
🤣10🤔9👍7
👍34🤣19🤔11🔥2🤩1
Awesome Nest Boilerplate architecture element generation based on Angular schematics 🎬
NarHakobyan
Please open Telegram to view this post
VIEW IN TELEGRAM
👍9🔥5❤3
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
Please open Telegram to view this post
VIEW IN TELEGRAM
👍8🔥3❤1
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
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
12%
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