The easiest way to start your online business! |
Tired of the 9-5 grind? Afraid of looking back 10… 20… 30 years from now and thinking… |
"What if I'd launched my idea into an online business?" |
Don't let your entrepreneurial dreams escape! |
If you can commit just 5 Days now, we'll show you how to build and launch your online business. Even if you have zero tech skills. |
Would it be worth 5 days to change the course of your life forever? |
Tap learn more to grab onto this opportunity while you still can! |
Learn more |
|
Can you figure out the regex to extract the colors from the string? |
|
|
Featured content |
BookBub: Get free bestsellers for Kindle, Nook, and more, as well as updates from your favorite authors. Check it out The Rundown AI: Get the rundown on the latest developments in AI before everyone else. Check it out
|
|
|
ES12 was truly an amazing upgrade. |
Packed with valuable features that completely transformed the way we write JavaScript. |
Code became cleaner, shorter, and easier to write. |
Let's check them out and see the ones you missed. |
1. Promise.any() |
Before ES12, we already had Promise.all() and Promise.allSettled() to wait for an entire group of Promises. |
There were several times when we'd have several Promises but only be interested in whichever one resolved first. |
So Promise.any() had to come into the picture: |
async function getHelpQuickly() { const response = await Promise.any([ cautiousHelper(), kindHelper(), wickedHelper(), ]); console.log(response); // Of course! } async function cautiousHelper() { await new Promise((resolve) => { setTimeout(() => { resolve('Uum, oohkaay?'); }, 2000); }); } async function kindHelper() { return 'Of course!'; } function wickedHelper() { return Promise.reject('Never, ha ha ha!!!'); } // codingbeautydev.com
|
One interesting thing to note: even though any() resolves immediately, the app doesn't end until all the Promises have resolved. |
|
2. replaceAll() |
Yes we already had replace() for quickly replace a substring within a string. |
const str = 'JavaScript is so terrible, it is unbelievably terrible!!'; const result = str.replace('terrible', 'wonderful'); console.log(result); // JavaScript is so wonderful, it is unbelievably terrible!! // Huh? // codingbeautydev.com
|
But it only did so for the first occurrence of the substring unless you use a regex. |
So ES12 gave us now we have replaceAll() to replace every single instance of that substring. |
const str = 'JavaScript is so terrible, it is unbelievably terrible.'; const result = str.replaceAll('terrible', 'wonderful'); console.log(result); // JavaScript is wonderful, it is unbelievably wonderful. // Now you're making sense! // codingbeautydev.com
|
|
|
How do computers actually understand the code we write? |
It's interesting how some people code for several years without ever learning these essentials. And often take it for granted. |
But how does a simple piece of text somehow control millions of screen pixels in a specific area with such incredible precision? |
And how does it interact so effortlessly with other computers thousands of miles away in the blink of an eye, using raw electricity? |
Let's dive into a fundamental overview of how it all works. |
What coding really is |
You see at their core, computers are nothing but a gigantic network of complex interconnected circuits. |
Everything your computer does comes from having electric current flow through the circuit. |
The core of computing is being able to use these currents as vessels for real-world data. |
In digital computing, there are only two states of current: On (1) or Off (0). Just like in a light switch. |
We use these two states to pass messages (instructions) to the complex circuit (processor/CPU). |
Because of the brilliant way we design the circuit, passing different instructions to the processor makes it "do" different things (a whole other subject on its own) |
In a 1-bit processor, you only have 2 possible instructions -- 1 or 0 (binary). |
But to make a full-fledged computer we need room for much more than two instructions. |
|
Thanks for taking the time to read today's issue. |
Don't let the bugs byte, Tari Ibaba |
0 Komentar untuk "How do computers actually understand the code you write?"