JavaScript
32.1K subscribers
1.05K photos
10 videos
33 files
726 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 obj = {
name: 'Sarah',
greet: () => {
console.log(`Hello, ${this.name}`);
},
sayHi: function() {
const inner = () => {
console.log(`Hi, ${this.name}`);
};
inner();
}
};

obj.greet();
obj.sayHi();
❀2
❀7🀣4πŸ€”2πŸ”₯1
CHALLENGE

class Observable {
constructor(subscribe) {
this.subscribe = subscribe;
}

map(fn) {
return new Observable(observer => {
return this.subscribe({
next: value => observer.next(fn(value)),
error: err => observer.error(err),
complete: () => observer.complete()
});
});
}
}

const source = new Observable(observer => {
observer.next(1);
observer.next(2);
observer.complete();
});

const doubled = source.map(x => x * 2);
doubled.subscribe({
next: value => console.log(value),
complete: () => console.log('done')
});
❀3πŸ€”2
❀2πŸ‘2πŸ”₯2πŸ€”2
πŸ’Œ Vite: The Documentary

From the same creators of the fantastic πŸ˜‰ Node.js, πŸ˜‰ Angular and πŸ˜‰ React documentaries comes an up to date look at Vite, the build tool that has taken the JavaScript ecosystem by storm in recent years. Many luminaries make an appearance to tell their stories, including Evan You, Rich Harris, and Ryan Carniato. (39 minutes.)

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

const obj = {
name: 'Sarah',
greet() {
return `Hello, ${this.name}`;
},
delayedGreet() {
const fn = function() {
return this.greet();
};
return fn.call(this);
}
};

const result = obj.delayedGreet();
console.log(result);
❀2
❀4πŸ‘1πŸ”₯1πŸ€”1🀩1
πŸ“₯ The Birth of Prettier

The author takes us back ten years to the genesis of Prettier, the popular opinionated, deterministic code formatter he co-created with James Long. Prettier effectively introduced and popularized the practice of fully-automated AST-based code formatting in the JavaScript ecosystem.

Christopher Chedeau (Vjeux)
Please open Telegram to view this post
VIEW IN TELEGRAM
❀10πŸ‘2πŸ”₯1
CHALLENGE

class Calculator {
static multiply(a, b) {
return a * b;
}

static add = (a, b) => {
return a + b;
}
}

class ScientificCalculator extends Calculator {
static multiply(a, b) {
return super.multiply(a, b) * 2;
}
}

console.log(Calculator.multiply(3, 4));
console.log(ScientificCalculator.add(5, 6));
console.log(ScientificCalculator.multiply(2, 3));
❀3
❀4πŸ€”3πŸ‘2πŸ”₯2
πŸ‘€ Viz.js 3.20: Work with Graphviz in the Browser

Graphviz is a suite of open source graph drawing tools of over 30 years’ vintage. Viz.js is a WebAssembly Graphviz build that brings its functionality into the browser. GitHub repo.

Michael Daines
Please open Telegram to view this post
VIEW IN TELEGRAM
❀6πŸ‘2πŸ”₯1
CHALLENGE

class Observable {
constructor(subscriber) {
this.subscriber = subscriber;
}

subscribe(observer) {
return this.subscriber(observer);
}

map(fn) {
return new Observable(observer => {
return this.subscribe({
next: value => observer.next(fn(value)),
error: err => observer.error(err),
complete: () => observer.complete()
});
});
}
}

const source = new Observable(observer => {
observer.next(1);
observer.next(2);
observer.complete();
});

const doubled = source.map(x => x * 2);
doubled.subscribe({
next: value => console.log(value),
complete: () => console.log('done')
});
❀4πŸ‘1πŸ”₯1
πŸ‘ The Firefox team has put together a way for you to give input on which Interop proposals matter the most to you (above). Go to the Interop Feature Ranking site (GitHub account required) and drag the web platform features that matter most for you to the top.
Please open Telegram to view this post
VIEW IN TELEGRAM
❀2πŸ‘1πŸ”₯1
CHALLENGE

const a = 9007199254740991n;
const b = BigInt(9007199254740991);
const c = 9007199254740992;
const d = BigInt(9007199254740992);

console.log(a === b);
console.log(Number(a) === c);
console.log(c === Number.MAX_SAFE_INTEGER + 1);
console.log(d > a);
console.log(typeof (a + 1n));
console.log(Number(d) === c);
CHALLENGE

const userInput = "<script>alert('xss')</script>";
const sanitized = userInput
.replace(/</g, '&lt;')
.replace(/>/g, '&gt;')
.replace(/"/g, '&quot;')
.replace(/'/g, '&#x27;');

const credentials = {
username: 'admin',
password: 'secret123'
};

const safeLog = (obj) => {
const { password, ...safe } = obj;
return JSON.stringify(safe);
};

console.log(sanitized);
console.log(safeLog(credentials));
❀3πŸ‘2πŸ”₯2