Daily Shaarli
April 26, 2023
const
only ensures that the reference is not modified. The data referenced can be modified though.
Also, primitive data types are immutable. So a const a = 5
can not be updated as 5 as Number can not change.
When we use const, we create an indestructible link between a variable name and a piece of data. We're still allowed to modify the data itself though!
La comparaison vaut le détour: quelle est la part de production du travailleur par an dédié au rendement du capital?
La part revenant aux salariés a en effet chuté dans le pays. Elle était de 75% au début des années 80, elle stagne autour de 65% aujourd’hui (source : INSEE).
Dans le même temps, 157 milliard d'euros sont versés sans contrepartie aux grandes entreprises.
How to create a web worker?
- Create a script that imports another one with
const worker = new Worker('worker.js'
- Bind events emitted by the worker with
worker.onmessage = function(event) { ... }
- Do the same in the web worker with
self.onmessage = function(event) { ... }
- Exchange messages with
worker.postMessage(payload)
orself.postMessage(payload)
One key difference between Web Workers and the main thread is that Web Workers have no access to the DOM or the UI. This means that they cannot directly manipulate the HTML elements on the page or interact with the user.