JavaScript
31.9K subscribers
1.01K photos
9 videos
33 files
693 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

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
πŸ‘8❀2πŸ”₯1πŸ€”1🀩1
🫑 GSAP v3.13: JavaScript Animation Set Free

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
πŸ€”10πŸ‘6
πŸ‘€ Export Google Analytics Data to Google Sheets via Apps Script

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
πŸ‘9❀2πŸ”₯2
🀩 PDFSlick 3.0: View and Interact with PDF Documents in JS Apps

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
❀3πŸ€”1
πŸ”₯ Crush Tech Interview Fear in 2025

Hovo Dallakyan
Please open Telegram to view this post
VIEW IN TELEGRAM
πŸ‘4❀2πŸ”₯1
CHALLENGE

const inventory = {
items: ['apple', 'banana', 'orange'],
[Symbol.iterator]: function() {
let index = 0;
const items = this.items;

return {
next: function() {
return index < items.length ?
{ value: items[index++].toUpperCase(), done: false } :
{ done: true };
}
};
}
};

const result = [...inventory].join(' + ');
console.log(result);
❀4πŸ‘4πŸ”₯1
πŸ‘5❀2πŸ”₯1🀩1
CHALLENGE

const obj = {};
const sym1 = Symbol('description');
const sym2 = Symbol('description');

obj[sym1] = 'Value 1';
obj[sym2] = 'Value 2';
obj.regularProp = 'Regular';

const allKeys = Object.getOwnPropertySymbols(obj).length + Object.keys(obj).length;
const comparison = sym1 === sym2;

console.log(allKeys + ',' + comparison);
❀3πŸ‘3πŸ”₯1
What is the output?
Anonymous Quiz
25%
3,true
32%
2,false
34%
3,false
9%
2,true
❀4πŸ‘4πŸ”₯3
CHALLENGE

const team = {
members: ['Alice', 'Bob', 'Charlie'],
leader: 'Diana',
[Symbol.iterator]: function*() {
yield this.leader;
for(const member of this.members) {
yield member;
}
}
};

let names = [];
for (const person of team) {
names.push(person);
}

console.log(names.join(', '));
❀6πŸ‘2
CHALLENGE

function processData(data) {
try {
if (!data) {
throw new TypeError('Data is required');
}

if (data.status === 'error') {
throw new Error('Invalid status');
}

return data.value.toUpperCase();
} catch (err) {
if (err instanceof TypeError) {
return 'Type Error';
}
return err.message;
}
}

console.log(processData({ status: 'error', value: 'test' }));
❀4
πŸ‘3πŸ”₯3❀2🀣1