CHALLENGE
function* genSequence() {
const result = yield 'first';
console.log(result);
yield* [1, 2];
return 'done';
}
const gen = genSequence();
let next = gen.next('ignored');
console.log(next.value);
next = gen.next('second');
next = gen.next();
console.log(next.value);
next = gen.next();
console.log(next);
π3β€2π₯1
A surprisingly featureful control for letting users pick fonts from a range of system fonts, Google fonts, and custom fonts of your choice. You can play with a code demo here or go to the GitHub repo.
Zygomatic
Please open Telegram to view this post
VIEW IN TELEGRAM
β€3π2π₯1
CHALLENGE
function Animal(name) {
this.name = name;
}
Animal.prototype.getName = function() {
return this.name;
};
function Dog(name, breed) {
Animal.call(this, name);
this.breed = breed;
}
Dog.prototype = Object.create(Animal.prototype);
Dog.prototype.constructor = Dog;
Dog.prototype.getName = function() {
return `Dog called ${Animal.prototype.getName.call(this)}`;
};
const myDog = new Dog('Rex', 'German Shepherd');
console.log(myDog.getName());
π₯5π1
π₯4β€1π1
Koa first appeared over a decade ago as a βnext-generationβ Web framework that shared some of the lineage (and team) of Express.js, but leaning on more modern JavaScript features and ideas of the time. While Express has been making a comeback recently, Koa has progressed too and offers a compelling alternative. v3.0 release notes.
Koa contributors
Please open Telegram to view this post
VIEW IN TELEGRAM
β€6π€©2π1π₯1
CHALLENGE
const obj = {
value: 42,
getValue() {
return this.value;
},
getValueArrow: () => this.value,
nested: {
value: 100,
getValue() {
return this.value;
}
}
};
const extractedMethod = obj.getValue;
const boundMethod = obj.getValue.bind(obj);
console.log(obj.getValue() + ',' + obj.getValueArrow() + ',' +
obj.nested.getValue() + ',' + extractedMethod() + ',' +
boundMethod());
β€2
What is the output?
Anonymous Quiz
34%
42,42,100,42,42
28%
42,undefined,100,42,42
16%
undefined,undefined,100,undefined,42
22%
42,undefined,100,undefined,42
π3β€2π₯2
I've been dabbling with a little C# recently and enjoyed this TypeScript is Like C# guide oriented largely around showing TypeScript/JavaScript vs C# examples of doing the same things.
Please open Telegram to view this post
VIEW IN TELEGRAM
π5β€3π₯3
CHALLENGE
const target = { a: 1, b: 2 };
const handler = {
get(obj, prop) {
return prop === 'sum' ? obj.a + obj.b : Reflect.get(obj, prop);
},
set(obj, prop, value) {
if (prop === 'a' && value < 0) {
return false;
}
return Reflect.set(obj, prop, value);
}
};
const proxy = new Proxy(target, handler);
proxy.a = -5;
proxy.b = 10;
console.log(`${proxy.a}, ${proxy.b}, ${proxy.sum}`);
π4π₯1
What is the output?
Anonymous Quiz
32%
-5, 10, 5
35%
undefined, 10, NaN
20%
-5, 10, NaN
14%
1, 10, 11
π8β€2π₯1π€1π€©1
Last year the popular GSAP (a.k.a. GreenSock) animation library was acquired by Webflow and as of this new version the entire GSAP toolkit is freely available (including formerly paid addons like MorphSVG and SplitText) even for commercial use. If you're unfamiliar with GSAP and want to see some of what it can do, they have a showcase, lots of code demos, and amazing docs.
Cassie Evans and Jack Doyle
Please open Telegram to view this post
VIEW IN TELEGRAM
π₯7β€2π2
CHALLENGE
const obj = {
value: 10,
getValue() {
return this.value;
},
getArrowValue: () => {
return this.value;
},
getMixedValue() {
const regular = function() { return this.value; };
const arrow = () => this.value;
return [regular(), arrow()];
}
};
console.log(obj.getMixedValue());
π1
What is the output?
Anonymous Quiz
20%
[undefined, undefined]
32%
[10, undefined]
27%
[undefined, 10]
21%
[10, 10]
π€10π6
Google Apps Script is a JavaScript-based platform for dynamically automating tasks in all sorts of Google apps. Hereβs how to use it to bring Google Analytics data into a Google Sheet.
Kayce Basques
Please open Telegram to view this post
VIEW IN TELEGRAM
π4β€1π₯1
CHALLENGE
const obj = {
value: 42,
getValue() {
return this.value;
},
getArrowValue: () => {
return this.value;
},
getDelayedValue() {
setTimeout(function() {
console.log(this.value);
}, 0);
},
getFixedDelayedValue() {
setTimeout(() => {
console.log(this.value);
}, 0);
}
};
obj.getDelayedValue();
β€3
What is the output?
Anonymous Quiz
19%
TypeError: Cannot read property 'value' of undefined
44%
42
32%
undefined
5%
null
π9β€2π₯2
A full-featured PDF viewer for React, Solid, Svelte and vanilla JS apps. Built on top of PDF.js, it offers a wide array of features from simple PDF viewing to working with multiple and large documents with annotations. Demo. v3.0 bumps up to PDF.js v5 with ICC profile support, better JPEG 2000 support, and improved rendering of large pages.
Vancho Stojkov
Please open Telegram to view this post
VIEW IN TELEGRAM
π4π₯2β€1π€©1
CHALLENGE
const target = { name: 'Alice' };
const handler = {
get(obj, prop) {
return prop in obj ? obj[prop].toUpperCase() : 'NOT_FOUND';
},
set(obj, prop, value) {
if (typeof value !== 'string') {
return false;
}
obj[prop] = value.trim();
return true;
}
};
const proxy = new Proxy(target, handler);
proxy.name = ' Bob ';
proxy.age = 30;
console.log(`${proxy.name}-${proxy.age}-${proxy.job}`);
π9
What is the output?
Anonymous Quiz
17%
BOB -30-NOT_FOUND
31%
Bob-30-undefined
36%
BOB-NOT_FOUND-NOT_FOUND
17%
BOB-30-NOT_FOUND
β€3π€1