<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Kllimenty Karavaev</title>
    <description>The latest articles on DEV Community by Kllimenty Karavaev (@thealmightymight).</description>
    <link>https://dev.to/thealmightymight</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F1279858%2Fed11fe92-665a-4ad3-a659-c8691e6c4a23.jpg</url>
      <title>DEV Community: Kllimenty Karavaev</title>
      <link>https://dev.to/thealmightymight</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/thealmightymight"/>
    <language>en</language>
    <item>
      <title>Тильда (~) в Go: что это и зачем нужно</title>
      <dc:creator>Kllimenty Karavaev</dc:creator>
      <pubDate>Tue, 09 Sep 2025 06:46:58 +0000</pubDate>
      <link>https://dev.to/thealmightymight/tilda-v-go-chto-eto-i-zachiem-nuzhno-43ia</link>
      <guid>https://dev.to/thealmightymight/tilda-v-go-chto-eto-i-zachiem-nuzhno-43ia</guid>
      <description>&lt;p&gt;Привет! Поговорим про оператор &lt;code&gt;~&lt;/code&gt; в Go, который многих сбивает с толку. Спойлер: это не одна, а целых две разные фичи в зависимости от контекста!&lt;/p&gt;

&lt;h2&gt;
  
  
  🤔 "Это что за знак такой?"
&lt;/h2&gt;

&lt;p&gt;Видите тильду в Go коде? Не паникуйте! Это либо:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Битовый переворот&lt;/strong&gt; (чаще всего)&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Магия дженериков&lt;/strong&gt; (в Go 1.18+)&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  🔄 Битовый NOT: переворачиваем биты
&lt;/h2&gt;

&lt;p&gt;Представьте, что у вас есть число, а тильда просто переворачивает все его биты в двоичном представлении:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight go"&gt;&lt;code&gt;&lt;span class="n"&gt;x&lt;/span&gt; &lt;span class="o"&gt;:=&lt;/span&gt; &lt;span class="m"&gt;5&lt;/span&gt;               &lt;span class="c"&gt;// 00000101 в двоичной системе счисления&lt;/span&gt;
&lt;span class="n"&gt;result&lt;/span&gt; &lt;span class="o"&gt;:=&lt;/span&gt; &lt;span class="o"&gt;^&lt;/span&gt;&lt;span class="n"&gt;x&lt;/span&gt;         &lt;span class="c"&gt;// 11111010 в двоичной системе счисления&lt;/span&gt;
&lt;span class="n"&gt;fmt&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Println&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;result&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;  &lt;span class="c"&gt;// 250 для uint8, -6 для int8&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Простая аналогия&lt;/strong&gt;: как если бы вы инвертировали цвета в фотошопе — белое становится черным, черное белым.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Где полезно&lt;/strong&gt;:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Работа с битовыми масками&lt;/li&gt;
&lt;li&gt;Шифрование и низкоуровневые операции&lt;/li&gt;
&lt;li&gt;Оптимизация памяти
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight go"&gt;&lt;code&gt;&lt;span class="c"&gt;// Пример: проверка бита&lt;/span&gt;
&lt;span class="k"&gt;const&lt;/span&gt; &lt;span class="n"&gt;ReadPermission&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="m"&gt;1&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span class="m"&gt;0&lt;/span&gt; &lt;span class="c"&gt;// 00000001&lt;/span&gt;
&lt;span class="k"&gt;const&lt;/span&gt; &lt;span class="n"&gt;WritePermission&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="m"&gt;1&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span class="m"&gt;1&lt;/span&gt; &lt;span class="c"&gt;// 00000010&lt;/span&gt;

&lt;span class="c"&gt;// Инвертируем маску чтобы получить все КРОМЕ определенных битов&lt;/span&gt;
&lt;span class="n"&gt;allExceptWrite&lt;/span&gt; &lt;span class="o"&gt;:=&lt;/span&gt; &lt;span class="o"&gt;^&lt;/span&gt;&lt;span class="n"&gt;WritePermission&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  🎯 Тильда в дженериках: aka "примерно такой тип"
&lt;/h2&gt;

&lt;p&gt;С Go 1.18 тильда получила особое значение в дженериках:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight go"&gt;&lt;code&gt;&lt;span class="c"&gt;// Ждет именно int&lt;/span&gt;
&lt;span class="k"&gt;func&lt;/span&gt; &lt;span class="n"&gt;StrictDouble&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;T&lt;/span&gt; &lt;span class="kt"&gt;int&lt;/span&gt;&lt;span class="p"&gt;](&lt;/span&gt;&lt;span class="n"&gt;x&lt;/span&gt; &lt;span class="n"&gt;T&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="n"&gt;T&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;x&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="m"&gt;2&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="c"&gt;// Принимает любой тип с underlying type int&lt;/span&gt;
&lt;span class="k"&gt;func&lt;/span&gt; &lt;span class="n"&gt;FlexibleDouble&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;T&lt;/span&gt; &lt;span class="err"&gt;~&lt;/span&gt;&lt;span class="kt"&gt;int&lt;/span&gt;&lt;span class="p"&gt;](&lt;/span&gt;&lt;span class="n"&gt;x&lt;/span&gt; &lt;span class="n"&gt;T&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="n"&gt;T&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;x&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="m"&gt;2&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="k"&gt;type&lt;/span&gt; &lt;span class="n"&gt;MyInt&lt;/span&gt; &lt;span class="kt"&gt;int&lt;/span&gt;

&lt;span class="k"&gt;func&lt;/span&gt; &lt;span class="n"&gt;main&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;var&lt;/span&gt; &lt;span class="n"&gt;num&lt;/span&gt; &lt;span class="n"&gt;MyInt&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="m"&gt;5&lt;/span&gt;
    &lt;span class="n"&gt;FlexibleDouble&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;num&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="c"&gt;// ✅ Работает!&lt;/span&gt;
    &lt;span class="n"&gt;StrictDouble&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;num&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;   &lt;span class="c"&gt;// ❌ Ошибка компиляции&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Перевод на человеческий&lt;/strong&gt;: &lt;code&gt;~int&lt;/code&gt; значит "любой тип, который под капотом является int". Не дискриминирует алиасы :)&lt;/p&gt;

&lt;h2&gt;
  
  
  💡 Практические советы
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Не путайте контексты&lt;/strong&gt;:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;В выражениях: &lt;code&gt;^x&lt;/code&gt; → битовая операция&lt;/li&gt;
&lt;li&gt;В дженериках: &lt;code&gt;[T ~int]&lt;/code&gt; → ограничение типа&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Для битовых операций&lt;/strong&gt;:&lt;br&gt;
&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight go"&gt;&lt;code&gt;   &lt;span class="c"&gt;// Включение бита&lt;/span&gt;
   &lt;span class="n"&gt;flags&lt;/span&gt; &lt;span class="o"&gt;|=&lt;/span&gt; &lt;span class="n"&gt;mask&lt;/span&gt;

   &lt;span class="c"&gt;// Выключение бита&lt;/span&gt;
   &lt;span class="n"&gt;flags&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;^=&lt;/span&gt; &lt;span class="n"&gt;mask&lt;/span&gt;  &lt;span class="c"&gt;// AND NOT&lt;/span&gt;

   &lt;span class="c"&gt;// Инверсия битов&lt;/span&gt;
   &lt;span class="n"&gt;flags&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="o"&gt;^&lt;/span&gt;&lt;span class="n"&gt;flags&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;В дженериках&lt;/strong&gt; используйте &lt;code&gt;~&lt;/code&gt; когда хотите принимать кастомные типы с нужным underlying type.&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  🚀 Итого
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;~&lt;/code&gt; — это два разных оператора в одном флаконе&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Битовый NOT&lt;/strong&gt;: переворачиваем биты&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Approximation constraint&lt;/strong&gt;: говорим дженерикам "принимай примерно такие типы"&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>webdev</category>
      <category>programming</category>
      <category>go</category>
      <category>tutorial</category>
    </item>
    <item>
      <title>The lesser known JavaScript features every senior developer should know</title>
      <dc:creator>Kllimenty Karavaev</dc:creator>
      <pubDate>Thu, 27 Feb 2025 15:36:31 +0000</pubDate>
      <link>https://dev.to/thealmightymight/the-lesser-known-javascript-features-every-senior-developer-should-know-4njn</link>
      <guid>https://dev.to/thealmightymight/the-lesser-known-javascript-features-every-senior-developer-should-know-4njn</guid>
      <description>&lt;p&gt;JavaScript is amazing and it has a ton of features that might not take the spotlight in your everyday coding but are as cool, useful and important as the rest of them. Besides, if you wanna become a senior developer, learning about every little detail about your porgramming language of choice is definitely a way to go. Let's dive in!&lt;/p&gt;

&lt;h2&gt;
  
  
  The optional chaining operator
&lt;/h2&gt;

&lt;p&gt;I know what you're thinking, I already know this one! And I mean sure, if you've been a JavaScript developer longer than like a few weeks you've probably come across the optional chaining operator many times as it is very helpful and widely adopted in most modern-day projects. However, this operator has more to offer than what can seem at first glance because not only you can use it to access non-existing properties on types that may not even be objects but you can also use it in combination with functions that may or may not be defined. Consider the following TypeScript code.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;notSoCoolFunction&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;someCallback&lt;/span&gt;&lt;span class="p"&gt;?:&lt;/span&gt; &lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="k"&gt;void&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="k"&gt;if&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;someCallback&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nf"&gt;someCallback&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;veryCoolFunction&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;someCallback&lt;/span&gt;&lt;span class="p"&gt;?:&lt;/span&gt; &lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="k"&gt;void&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nx"&gt;someCallback&lt;/span&gt;&lt;span class="p"&gt;?.();&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Here we have two differently named functions that execute pretty much the same code. The only difference is that in &lt;code&gt;notSoCoolFunction&lt;/code&gt;, we have to explicitly run a check if the &lt;code&gt;someCallback&lt;/code&gt; was indeed provided as an argument, whereas &lt;code&gt;veryCoolFunction&lt;/code&gt; doesn't make any explicit runtime checks to determine if we've been provided a callback function or not. It simply calls the optional &lt;code&gt;someCallback&lt;/code&gt; function utilizing the optional chaining operator syntax.&lt;/p&gt;

&lt;p&gt;As you might have noticed, the syntax is much shorter and readable as we don't have to make any assertions about whether this optional &lt;code&gt;someCallback&lt;/code&gt; argument is omitted or not. Of course, that doesn't affect the correctness of our program's execution because if the &lt;code&gt;someCallback&lt;/code&gt; is omitted, the JS engine will simply continue to execute other code, and no runtime errors like &lt;code&gt;TypeError&lt;/code&gt; will be thrown. Pretty neat don't you think?&lt;/p&gt;

&lt;p&gt;You can find more about it &lt;a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Optional_chaining" rel="noopener noreferrer"&gt;here&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  The &lt;code&gt;new.target&lt;/code&gt; meta-property
&lt;/h2&gt;

&lt;p&gt;Here's something 98% of JavaScript developers have never even seen being used as it is rather an old feature introduced in some of the earlier versions of ECMAScript, rarely applicable unless you're doing some very obscure OOP magic in your code.&lt;/p&gt;

&lt;p&gt;Here's what it is: &lt;strong&gt;new.target&lt;/strong&gt; is a meta-property that lets you detect whether a function or constructor was called using the &lt;a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/new" rel="noopener noreferrer"&gt;&lt;code&gt;new&lt;/code&gt;&lt;/a&gt; operator. In constructors and functions invoked using the &lt;a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/new" rel="noopener noreferrer"&gt;&lt;code&gt;new&lt;/code&gt;&lt;/a&gt; operator, &lt;strong&gt;new.target&lt;/strong&gt; returns a reference to the constructor or function that &lt;strong&gt;new&lt;/strong&gt; was called upon. In normal function calls, &lt;strong&gt;new.target&lt;/strong&gt; is &lt;a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/undefined" rel="noopener noreferrer"&gt;&lt;code&gt;undefined&lt;/code&gt;&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;The &lt;code&gt;new.target&lt;/code&gt; syntax consists of the keyword &lt;strong&gt;new&lt;/strong&gt;, a dot, and the identifier &lt;strong&gt;target&lt;/strong&gt;. Because &lt;strong&gt;new&lt;/strong&gt; is a &lt;a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Lexical_grammar#reserved_words" rel="noopener noreferrer"&gt;reserved word&lt;/a&gt;, not an identifier, this is not a &lt;a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Property_accessors" rel="noopener noreferrer"&gt;property accessor&lt;/a&gt;, but a special expression syntax.&lt;/p&gt;

&lt;p&gt;The &lt;strong&gt;new.target&lt;/strong&gt; meta-property is available in all function/class bodies; using &lt;strong&gt;new.target&lt;/strong&gt; outside of functions or classes is a syntax error.&lt;/p&gt;

&lt;p&gt;One practical example of how it can be used is checking whether a function is called as a constructor or as a regular function:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;Foo&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="k"&gt;if &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="o"&gt;!&lt;/span&gt;&lt;span class="k"&gt;new&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;target&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;throw&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;TypeError&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;calling Foo constructor without new is invalid&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="k"&gt;try&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nc"&gt;Foo&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;catch &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;e&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;e&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="c1"&gt;// Expected output: TypeError: calling Foo constructor without new is invalid&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You can read more about it &lt;a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/new.target" rel="noopener noreferrer"&gt;here&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  The void operator
&lt;/h2&gt;

&lt;p&gt;Alright then, let's finish off with yet another lesser-known JavaScript feature that can be quite handy in certain situations: the &lt;code&gt;void&lt;/code&gt; operator. This operator is used to discard the return value of an expression, effectively returning undefined. It's particularly useful when you want to evaluate an expression for its side effects but don't care about its return value.&lt;/p&gt;

&lt;p&gt;Let's start with a simple example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="k"&gt;void&lt;/span&gt; &lt;span class="mi"&gt;42&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt; &lt;span class="c1"&gt;// Outputs: undefined&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In this example, the &lt;code&gt;void&lt;/code&gt; operator discards the value &lt;code&gt;42&lt;/code&gt;, resulting in &lt;code&gt;undefined&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;Now, let's dive into a more practical use case involving IIFEs (Immediately Invoked Function Expressions). Sometimes, you might want to execute a function immediately without leaving any trace of its return value. Here's how you can do it:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="k"&gt;void&lt;/span&gt; &lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;iifeExample&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;This function runs immediately!&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;You won't see this!&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}();&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In this example, the IIFE &lt;code&gt;iifeExample&lt;/code&gt; is executed immediately upon definition. The &lt;code&gt;void&lt;/code&gt; operator ensures that the return value of the function is discarded, so even though the function returns a string, it won't be used or stored anywhere. This can be useful in scenarios where you want to run some initialization code without polluting the global scope with unnecessary return values.&lt;/p&gt;

&lt;p&gt;The &lt;code&gt;void&lt;/code&gt; operator is a neat tool to have in your JavaScript toolkit, allowing you to write cleaner and more intentional code, especially when dealing with expressions where the return value is not needed.&lt;/p&gt;

&lt;p&gt;You can find more about it &lt;a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/void" rel="noopener noreferrer"&gt;here&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Now I have a question to the audience, how often do you encounter any of these JavaScript features in your daily coding routine as a developer? I'd be thrilled to hear about your experience, let me know in the comments!&lt;/p&gt;

</description>
      <category>webdev</category>
      <category>javascript</category>
      <category>node</category>
      <category>typescript</category>
    </item>
  </channel>
</rss>
