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👍1🔥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);
❤6
What is the output?
Anonymous Quiz
17%
true, false, true, true
31%
true, true, true, undefined
40%
true, true, true, false
13%
true, false, true, false
🔥5❤2👍2
npq performs several extra steps compared to npm. It consults Snyk’s database of vulnerabilities, looks at the package’s age, download count, and docs, and tries to paint a better picture of what you’re really installing.
Liran Tal
Please open Telegram to view this post
VIEW IN TELEGRAM
🔥5👍3❤1
CHALLENGE
class LightMachine {
constructor() {
this.states = {
green: { next: 'yellow' },
yellow: { next: 'red' },
red: { next: 'green' }
};
this.currentState = 'green';
}
transition() {
this.currentState = this.states[this.currentState].next;
return this.currentState;
}
}
const lightMachine = new LightMachine();
let result = '';
for (let i = 0; i < 5; i++) {
result += lightMachine.transition() + ' ';
}
console.log(result.trim());
❤2
What is the output?
Anonymous Quiz
48%
yellow red green yellow red
24%
yellow red green red yellow
14%
red green yellow red green
15%
green yellow red green yellow
❤8
CHALLENGE
async function processValues() {
try {
console.log('Start');
const a = await Promise.resolve('First');
console.log(a);
const b = await Promise.reject('Error');
console.log(b);
return 'Done';
} catch (err) {
console.log(err);
return 'Recovered';
} finally {
console.log('Finally');
}
}
processValues().then(result => console.log(result));
What is the output?
Anonymous Quiz
33%
Start First Error Finally Recovered
23%
Start First Finally Recovered
41%
Start First Error Recovered Finally
3%
Start First Finally Error Recovered
👍4❤1🔥1