JavaScript
31.1K subscribers
1.23K photos
10 videos
33 files
895 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
❤6
CHALLENGE

const a = 5 & 3;
const b = 5 | 2;
const c = ~5;
const d = 1 << 31;
const e = -1 >>> 28;
const f = 5 ^ 5;
console.log(a, b, c, d, e, f);
CHALLENGE

'use strict';

function getValue() {
return this.value;
}

const obj = { value: 42, getValue };
const fn = obj.getValue;

try {
fn();
} catch (err) {
console.log(err.constructor.name, typeof this);
}
❤2
CHALLENGE

console.log(
typeof typeof 1,
1 + typeof 1,
2 ** 3 ** 2,
1 + 2 + '3',
1 < 2 < 3,
3 > 2 > 1
);
🔥2
CHALLENGE

function Foo(x) {
this.x = x;
return { x: x * 2 };
}

function Bar(x) {
this.x = x;
return 42;
}

const f = new Foo(5);
const b = new Bar(5);

console.log(f.x, b.x, f instanceof Foo, b instanceof Bar);
❤4
CHALLENGE

function* inner() {
yield 1;
yield 2;
return 100;
}

function* outer() {
const result = yield* inner();
yield result;
yield 3;
}

const it = outer();
console.log(it.next().value, it.next().value, it.next().value, it.next().value);
❤5👍2🤔1
❤1
🤩 tinyjs: Build JavaScript Desktop Apps in <10MB

I built an app with this and was impressed. You get a txiki.js-powered backend with full system access (including FFI!), native webview rendering, and tiny macOS, Linux, and Windows builds. It even makes it easy to sign/notarize the final app.

Tarwin Stroh-Spijer
Please open Telegram to view this post
VIEW IN TELEGRAM
❤6👍2
CHALLENGE

class Base {
static count = 0;
static increment() {
this.count++;
return this.count;
}
}

class Derived extends Base {
static count = 10;
}

console.log(Base.increment(), Derived.increment(), Base.count, Derived.count);
❤2🔥2👍1
CHALLENGE

let counter = 0;
const mod = {
get counter() { return counter; },
increment() { counter++; }
};

const { counter: snapshotCounter } = mod;
mod.increment();
mod.increment();

console.log(snapshotCounter, mod.counter, counter);
❤1🔥1
What is the output?
Anonymous Quiz
31%
0 2 2
28%
0 0 0
20%
0 1 2
21%
2 2 2
❤1🔥1🤣1
CHALLENGE

const obj = {
value: 42,
getValue() { return this?.value; },
getValueArrow: () => this?.value
};
const { getValue, getValueArrow } = obj;
console.log(obj.getValue(), getValue(), obj.getValueArrow(), getValueArrow());
CHALLENGE

class Base {
value = 10;
getValue = () => this.value;
constructor() {
this.value = 20;
}
}

class Derived extends Base {
value = 30;
}

const d = new Derived();
console.log(d.getValue(), d.value);
❤2
What is the output?
Anonymous Quiz
23%
10 30
43%
20 30
13%
20 20
21%
30 30