JavaScript
31.9K subscribers
1.01K photos
9 videos
33 files
697 links
A resourceful newsletter featuring the latest and most important news, articles, books and updates in the world of #javascript πŸš€ Don't miss our Quizzes!

Let's chat: @nairihar
Download Telegram
CHALLENGE

async function fetchData() {
console.log('1');
return Promise.resolve('data');
}

async function processData() {
console.log('2');
const result = await fetchData();
console.log('3');
return result;
}

console.log('4');
processData().then(() => console.log('5'));
console.log('6');
❀4πŸ‘2πŸ€”2
πŸ‘‘ Cronicle: Cron with a Web Front End

Describing itself as β€˜a fancy cron replacement’, Cronicle is a distributed task scheduler and runner, built around a Node app with a web based UI. GitHub repo.

Joseph Huckaby
Please open Telegram to view this post
VIEW IN TELEGRAM
❀5πŸ‘5πŸ”₯1
CHALLENGE

const arr = new Array(1000000).fill(0).map((_, i) => i);
const results = [];

function method1() {
return arr.filter(x => x % 2 === 0).map(x => x * 2).slice(0, 3);
}

function method2() {
const result = [];
for (let i = 0; i < arr.length && result.length < 3; i++) {
if (arr[i] % 2 === 0) {
result.push(arr[i] * 2);
}
}
return result;
}

console.log(method1().join(','));
console.log(method2().join(','));
What is the output?
Anonymous Quiz
13%
0,2,4
58%
0,4,8 0,4,8
18%
2,4,6
11%
0,4,8
❀1πŸ‘1πŸ”₯1
😈 Sam Rose has put together a fantastic illustrated introduction to Big O notation, along with JavaScript examples. If you've ever wondered what O(1), O(log n), etc. mean, this is a great primer.
Please open Telegram to view this post
VIEW IN TELEGRAM
❀6πŸ‘3πŸ”₯1
CHALLENGE

const obj = { a: 1, b: { c: 2 } };
const frozen = Object.freeze(obj);
frozen.a = 99;
frozen.b.c = 88;
frozen.d = 77;

const sealed = Object.seal({ x: 10, y: 20 });
sealed.x = 30;
sealed.z = 40;
delete sealed.y;

console.log(obj.a, obj.b.c, obj.d);
console.log(sealed.x, sealed.y, sealed.z);