π€£6π3β€2π€2
The Ultimate Guide to Understanding EventLoop in Node.js
This comprehensive guide is going to take some time to cover every detail that you need to know, so grab a cup of coffee and settle in for an exciting journey to the fascinating world of Node.js. Letβs get started!
nairihar
Please open Telegram to view this post
VIEW IN TELEGRAM
β€8π3π₯2
CHALLENGE
const compose = (...fns) => x => fns.reduceRight((acc, fn) => fn(acc), x);
const addTwo = num => num + 2;
const multiplyByThree = num => num * 3;
const subtractTen = num => num - 10;
const calculate = compose(subtractTen, multiplyByThree, addTwo);
console.log(calculate(5));
β€5π₯3π1
What is the output?
Anonymous Quiz
11%
7
43%
11
37%
((5 + 2) * 3) - 10 = 11
9%
(5 + 2) * 3 - 10 = 11
β€5π€3π2
From Chrome 137 you can try out CSS inline conditionals with the if() function. if() enables a cleaner developer interface for dynamic styles like style queries and media queries, with some key differences, which you can learn about in this post.
Please open Telegram to view this post
VIEW IN TELEGRAM
β€10π4π₯2
CHALLENGE
function Vehicle(wheels) {
this.wheels = wheels;
}
Vehicle.prototype.getWheels = function() {
return this.wheels;
};
function Car() {
Vehicle.call(this, 4);
this.doors = 4;
}
Car.prototype = Object.create(Vehicle.prototype);
Car.prototype.constructor = Car;
const myCar = new Car();
console.log(myCar.getWheels(), myCar instanceof Vehicle);
β€5
What is the output?
Anonymous Quiz
17%
4 false
48%
4 true
28%
TypeError: myCar.getWheels is not a function
6%
undefined true
β€4π₯3π€3π1
Please open Telegram to view this post
VIEW IN TELEGRAM
β€5π₯3π2
CHALLENGE
function getOrder() {
console.log('1');
setTimeout(() => console.log('2'), 0);
Promise.resolve().then(() => {
console.log('3');
Promise.resolve().then(() => console.log('4'));
});
Promise.resolve().then(() => console.log('5'));
console.log('6');
}
getOrder();
β€4
π8β€4π₯3
The Oxidation Compiler is creating a collection of high-performance tools for JavaScript and TypeScript.
Please open Telegram to view this post
VIEW IN TELEGRAM
β€5π€2π1π₯1
CHALLENGE
const scores = [85, 92, 78, 90];
const student = {
name: 'Jordan',
grade: 'A',
...{ courses: ['Math', 'Science'] },
scores,
average: function() { return this.scores.reduce((a, b) => a + b) / this.scores.length }
};
const { name, ...details } = student;
const [first, ...rest] = scores;
console.log(details.scores[0], rest[0]);
β€5π₯2
π₯3π2π€2β€1
CHALLENGE
function* createCounter() {
let count = 0;
while (true) {
const reset = yield ++count;
if (reset) {
count = 0;
}
}
}
const counter = createCounter();
console.log(counter.next().value);
console.log(counter.next().value);
console.log(counter.next(true).value);
console.log(counter.next().value);
β€9π2π€©1
π5
CHALLENGE
function createCounter() {
let count = 0;
const counter = {
increment() {
count++;
return count;
},
getCount() {
return count;
}
};
return counter;
}
let c1 = createCounter();
c1.increment();
c1.increment();
let c2 = c1;
c1 = null;
console.log(c2.getCount());
β€3π1π₯1
What is the output?
Anonymous Quiz
21%
null
27%
undefined
21%
ReferenceError: count is not defined
31%
2
π€6π5β€1π₯1
In June we featured php-node, a new way to βbridge the gapβ between PHP and Node.js by being able to embed PHP into Node apps. Now theyβve gone a step further by using php-node and the Watt app server to enable the running of Laravel apps too. A curious meeting of ecosystems!
Stephen Belanger (Platformatic)
Please open Telegram to view this post
VIEW IN TELEGRAM
β€4π2π₯1π€1
CHALLENGE
const weakSet = new WeakSet();
const obj1 = { name: 'First' };
const obj2 = { name: 'Second' };
const obj3 = obj1;
weakSet.add(obj1);
weakSet.add(obj2);
let result = '';
result += weakSet.has(obj1) + ', ';
result += weakSet.has(obj3) + ', ';
obj2.name = 'Modified';
result += weakSet.has(obj2) + ', ';
weakSet.delete(obj1);
result += weakSet.has(obj3);
console.log(result);
β€7π₯1
What is the output?
Anonymous Quiz
17%
true, false, true, true
30%
true, true, true, undefined
41%
true, true, true, false
13%
true, false, true, false
π₯6π3β€2