
Title



If GitHub stars mean anything then
Unfollowing MAGA and anti-MAGA.
It’s all just complacent, boring anti-politics.
The spread operator, which is denoted by three dots … , is a very versatile and powerful feature of modern JavaScript.
It has four major uses:
* array spreads are just a special case of spreads with Iterables (more soon).
Function application simply means calling functions but JavaScript functions come with an apply() method that enables you to call that function while passing an array for arguments.
f = (a, b, c) => a + b + c;
args = [ 1, 2, 3 ]
f.apply(null, args);
Result
> 6
You can use the spread operator as an alternative to apply().
f(...args);
You can also mix and match your arguments
f(10, ...[20, 30])
f(...[10, 20], 30)
f(10, ...[20], 30)
Result
> 60
For a given array:
arr1 = [ 1, 2, 3 ];
you can use the spread operator to create a shallow copy of the array
arr2 = [ ...arr2 ];
Result
> arr2 = [ 1, 2, 3 ];
You can also use the spread operator to prepend an element to an array
arr1 = [ 1, 2, 3 ];
arr2 = [ 0, ...arr1 ];
Result
> arr2 = [ 0, 1, 2, 3 ]
Or you can use the spread operator to append an element to an array
arr1 = [ 1, 2, 3 ];
arr2 = [ ...arr1, 4 ];
Result
> arr2 = [ 1, 2, 3, 4 ]
you can also use the spread operator to concatenate multiple arrays
arr1 = [ 1, 2, 3 ];
arr2 = [ 4, 5, 6 ];
arr3 = [ 7, 8, 9 ];
arr4 = [ ...arr1, ...arr2, ...arr3 ];
Result
> arr4 = [ 1, 2, 3, 4, 5, 6, 7, 8, 9 ]
The spread operator can be used in any location of the receiving object and be mixed with normal key assignments
arr1 = [ 1, 2, 3 ];
arr2 = [ 4, 5, 6 ];
arr3 = [ 100, ...arr1, 200, ...arr2, 300 ];
Result
> arr3 = [ 100, 1, 2, 3, 200, 4, 5, 6, 300 ]
The spread operator for objects works in a very similar way to the spread operator for arrays/iterables but its behaviour is subtly different. It is useful for spreading the key-value pairs of an object into another object
For a given object:
obj1 = { a: 1, b: 2, c: 3 };
you can create a shallow copy using the spread operator
obj2 = { ...obj1 };
Result
> obj2 = { a:1, b:2, c:3 }
you can also use the spread operator to merge multiple objects together
obj1 = { a: 1, b: 2, c: 3 };
obj2 = { d: 4, e: 5, f: 6 };
obj3 = { g: 7, h: 8, i: 9 };
obj4 = { ...obj1, ...ob2, ...obj3 };
Result
> obj4 = { a:1, b:2, c:3, d:4, e:5, f:6, g: 7, h: 8, i: 9 }
you can use the spread operator in any location of the receiving object and mix it with normal key-value assignments
obj1 = { a: 1, b: 2, c: 3 };
obj2 = { d: 4, e: 5, f: 6 };
a = 100
b = 200
obj3 = { a, ...obj1, b, ...ob2, c: 300 };
Result
> obj3 = { a: 1, b: 200, c: 300, d: 4, e: 5, f: 6 }
NOTE: If keys get repeated the value gets overridden with the last assigned value.
NOTE: Key order is preserved in JavaScript based on insertion order.
obj1 = { a: 1, b: 2, c: 3 };
obj2 = { c: 10, ...obj1 }
Result
> obj2 = { c: 3, a: 1, b: 2 }
Object.keys(obj2);
> [ 'c', 'a', 'b' ]
Because the spread operator for objects treats its argument as a simple object. This means that it treats arrays and other iterable types as objects which have their index as a key.
Given the array
arr1 = [ 10, 20, 30 ]
The object spread operator will treat the array as simple object
obj1 = { ...arr1 };
Result
> obj1 = { 0: 10, 1: 20, 2: 30 }
Given the string
str1 = 'Hello';
The object spread operator will treat the string as simple object
obj1 = { ...str1 };
Result
> obj1 = { 0: 'H', 1: 'e', 2: 'l', 3: 'l', 4: 'o' }
The War Nerd is always worth reading.
Originally shared by Jeff Zahari
“When oil, money, and a huge international alliance all line up with the people starving out a troublesome minority, you can expect a complete media blackout on news about those who are dying.”
The main benefit Typescript offers here is to make the purpose of monadic bind (flatMap) clearer than it would be using dynamically typed JavaScript.
Part 2
https://codewithstyle.info/advanced-functional-programming-typescript-monads-generators/
Part 3
https://codewithstyle.info/advanced-functional-programming-typescript-functional-exceptions/
Jeff Bezos Is Already $40 Billion Richer This Year—While the Typical Amazon Worker Has Made Just $12,000
If you think this is bad, just wait until the typical Amazon worker is making $6,000 a year.
Originally shared by Teodor Poparescu
Are we going to acknowledge that this kind of obscene accumulation of wealth, while some of Amazon’s employees are depending on food stamps, isn’t just unethical, but also pathological?

Peak Liberalism.
Every American (and Western) leader has an innate sympathy for authoritarian dictators. The West has always been comfortable dealing with the most brutal tyrants. They love them.
So what’s different here? The Koreans, both North and South want peace. The South elected a president who is dedicated to ending the war. Western liberals on the other hand are so fucked in the head that they actually want war. That’s why they fawn over every word of the Washington warhawks, a group that should be facing charges in the Hague rather than being given regular columns and TV spots.
Originally shared by Jürgen Hubert
‘Trumpian chaos is, in fact, undergirded by a comprehensible worldview, a number of experts have insisted. The Brookings Institution scholar (and frequent Atlantic contributor) Thomas Wright argued in a January 2016 essay that Trump’s views are both discernible and explicable. Wright, who published his analysis at a time when most everyone in the foreign-policy establishment considered Trump’s candidacy to be a farce, wrote that Trump loathes the liberal international order and would work against it as president; he wrote that Trump also dislikes America’s military alliances, and would work against them; he argued that Trump believes in his bones that the global economy is unfair to the U.S.; and, finally, he wrote that Trump has an innate sympathy for “authoritarian strongmen.”’