<?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>Forem: Jitendra</title>
    <description>The latest articles on Forem by Jitendra (@jimmy1995).</description>
    <link>https://forem.com/jimmy1995</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%2F1153824%2F896dc824-b5dd-4c60-a445-684c19a63dca.png</url>
      <title>Forem: Jitendra</title>
      <link>https://forem.com/jimmy1995</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://forem.com/feed/jimmy1995"/>
    <language>en</language>
    <item>
      <title>A Guide to Converting ASCII to Characters in JavaScript</title>
      <dc:creator>Jitendra</dc:creator>
      <pubDate>Wed, 03 Jan 2024 15:04:40 +0000</pubDate>
      <link>https://forem.com/jimmy1995/a-guide-to-converting-ascii-to-characters-in-javascript-ih</link>
      <guid>https://forem.com/jimmy1995/a-guide-to-converting-ascii-to-characters-in-javascript-ih</guid>
      <description>&lt;h2&gt;
  
  
  Introduction:
&lt;/h2&gt;

&lt;p&gt;In the vast world of programming, understanding the fundamentals is crucial. One such fundamental concept is ASCII (American Standard Code for Information Interchange). ASCII codes, representing characters as numerical values, play a vital role in various applications. This post will teach us how to use JavaScript to convert ASCII codes to characters.&lt;/p&gt;

&lt;h2&gt;
  
  
  Understanding ASCII:
&lt;/h2&gt;

&lt;p&gt;ASCII is a character encoding standard that assigns a unique numerical value to each character. For example, the ASCII code for the letter 'A' is 65, 'B' is 66, and so on. This encoding scheme allows computers to represent text characters in a standardized way.&lt;/p&gt;

&lt;h2&gt;
  
  
  The Journey Begins: Writing the Conversion Function:
&lt;/h2&gt;

&lt;p&gt;In JavaScript, the process of converting ASCII codes to characters is straightforward. We can leverage the &lt;code&gt;String.fromCharCode()&lt;/code&gt; method to achieve this transformation. Let's explore a simple function that encapsulates this process:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const ASCIIToChar = (asciiCode) =&amp;gt; {
  return String.fromCharCode(asciiCode);
};

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;code&gt;The String.fromCharCode()&lt;/code&gt; method takes one or more Unicode values and returns the corresponding characters. In this case, we provide it with a single ASCII code to obtain the character it represents.&lt;/p&gt;

&lt;h2&gt;
  
  
  Putting the Function to the Test:
&lt;/h2&gt;

&lt;p&gt;Now that we have our conversion function, let's put it to the test with some examples:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;console.log(ASCIIToChar(65)); // Output: 'A'
console.log(ASCIIToChar(97)); // Output: 'a'
console.log(ASCIIToChar(33)); // Output: '!'

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You can use &lt;a href="https://www.fireboxtools.com/text-tools/ascii-to-string"&gt;ASCII to text converter&lt;/a&gt; to verify your output or convert ASCII codes to text online.&lt;/p&gt;

&lt;h2&gt;
  
  
  Handling Arrays of ASCII Codes:
&lt;/h2&gt;

&lt;p&gt;What if you have an array of ASCII codes that you want to convert to a string? Fear not; JavaScript has you covered. We can modify our function to handle arrays of ASCII codes:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const ASCIIToString = (asciiArray) =&amp;gt; {
  return String.fromCharCode(...asciiArray);
};

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now, you can convert an array of ASCII codes into a string effortlessly:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const asciiArray = [72, 101, 108, 108, 111];
console.log(ASCIIToString(asciiArray)); // Output: 'Hello'

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Real-World Applications:
&lt;/h2&gt;

&lt;p&gt;Understanding how to convert ASCII codes to characters opens the door to various real-world applications. You might encounter scenarios where data is encoded using ASCII and decoding it into readable text becomes a necessity&lt;/p&gt;

&lt;h3&gt;
  
  
  Conclusion:
&lt;/h3&gt;

&lt;p&gt;In this exploration of converting ASCII codes to characters in JavaScript, we've equipped ourselves with a fundamental skill. The ability to decode ASCII opens up numerous possibilities in programming. Whether you're working with textual data or diving into the intricacies of character encoding, mastering the conversion from ASCII codes to characters is a journey well worth taking. Happy coding!&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>react</category>
      <category>typescript</category>
    </item>
    <item>
      <title>Top 5 Programming Languages to Learn in 2024</title>
      <dc:creator>Jitendra</dc:creator>
      <pubDate>Tue, 26 Sep 2023 14:13:18 +0000</pubDate>
      <link>https://forem.com/jimmy1995/top-5-programming-languages-to-learn-in-2024-a4j</link>
      <guid>https://forem.com/jimmy1995/top-5-programming-languages-to-learn-in-2024-a4j</guid>
      <description>&lt;p&gt;The technological landscape always evolves and is everchanging. &lt;br&gt;
Similarly, the trend of languages also changes. &lt;/p&gt;

&lt;p&gt;Based on current trends and market predictions, the top five programming languages predicted to be in high demand in 2024 are:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;1. Python&lt;/strong&gt;: Known for its simplicity and versatility, Python continues to be a popular choice for data analysis, artificial intelligence, and machine learning.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;2. JavaScript&lt;/strong&gt;: With the rise of online applications and the dominance of front-end development, JavaScript continues to be an important language for creating interactive and dynamic web pages.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;3. Go&lt;/strong&gt;: Go's popularity for systems and network programming can be attributed to its efficiency, strong support for concurrent programming, well-designed standard library, portability, and backing from Google. Its simplicity and focus on readability also contribute to its appeal, making it an excellent choice for building scalable, high-performance, and concurrent software systems.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;4. Rust&lt;/strong&gt;: Rust's ownership system is a groundbreaking feature that ensures memory safety without the need for a garbage collector. It enforces strict rules at compile time, preventing common issues like null pointer dereferences, data races, and buffer overflows&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;5. Java&lt;/strong&gt;: Java's design and architecture make it well-suited for building large and complex applications. It's object-oriented programming (OOP) features, modular structure, and strong typing allow developers to design scalable and maintainable codebases&lt;/p&gt;

&lt;p&gt;In conclusion, the programming languages landscape is ever-evolving, and it's important for developers and aspiring programmers to stay updated with the latest trends.&lt;/p&gt;

</description>
    </item>
    <item>
      <title>Make properties optional in TypeScript</title>
      <dc:creator>Jitendra</dc:creator>
      <pubDate>Thu, 21 Sep 2023 09:58:36 +0000</pubDate>
      <link>https://forem.com/jimmy1995/make-properties-optional-in-typescript-1mao</link>
      <guid>https://forem.com/jimmy1995/make-properties-optional-in-typescript-1mao</guid>
      <description>&lt;p&gt;I just came into a situation where I needed to mark one or more keys optional in a TypeScript interface.&lt;/p&gt;

&lt;p&gt;Let’s say that I have an interface of three keys &lt;code&gt;name&lt;/code&gt;, &lt;code&gt;age&lt;/code&gt;, and &lt;code&gt;email&lt;/code&gt;.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;interface User {
  name: string;
  age: number;
  email: string
}

// 👍 OK, name, age, and email are defined
const pawel: User = {
  name: "Pawel Grzybek",
  age: 34,
  email: "email@email.com"
};
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In today's modern world, if you have a small or large JSON object and want to create an interface for it, don't waste your time doing it manually. You can use an online &lt;a href="https://www.fireboxtools.com/json-tools/json-to-typescript-interface"&gt;JSON to Typescript converter&lt;/a&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  Make all properties optional except one in TypeScript
&lt;/h2&gt;

&lt;p&gt;Now I have a case in which I want to assign only &lt;code&gt;name&lt;/code&gt; and &lt;code&gt;age&lt;/code&gt; without email.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;interface User {
  name: string;
  age: number;
  email: string
}

// 👎 Uuups, Property 'email' is missing
const pawel: User = {
  name: "Pawel Grzybek",
  age: 34
};
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;To handle this situation, TypeScript provides a handy utility type &lt;a href="https://www.typescriptlang.org/docs/handbook/utility-types.html#partialtype"&gt;Partial&lt;/a&gt;. Which converts all keys to optional.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;interface User {
  name: string;
  age: number;
  email: string
}

interface OptionalExceptEmail extends Partial&amp;lt;User&amp;gt;  {
  email?: string
}

// 👍 OK, all looks good
const pawel: OptionalExceptEmail = {
  name: "Pawel Grzybek",
  age: 34
};
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Make a single or multiple properties optional in Typescript
&lt;/h2&gt;

&lt;p&gt;To solve using best practices in Typescript. I will create another type to make it work.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;interface Dev {
  language: string;
  age: number;
  experience: number;
}

type MakeOptional&amp;lt;Type, Key extends keyof Type&amp;gt; = Omit&amp;lt;Type, Key&amp;gt; &amp;amp;
  Partial&amp;lt;Pick&amp;lt;Type, Key&amp;gt;&amp;gt;;

// 👍 mark experience as optional
type T1 = MakeOptional&amp;lt;Dev, 'experience'&amp;gt;;

const dev1: T1 = {
  age: 30,
  language: 'ts',
};

// 👍 mark experience and age as optional
type T2 = MakeOptional&amp;lt;Dev, 'experience' | 'age'&amp;gt;;

const dev2: T2 = {
  language: 'ts',
};
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Make all properties optional in TypeScript
&lt;/h2&gt;

&lt;p&gt;To make all properties optional. Again I will use an amazing utility called &lt;code&gt;Partial&lt;/code&gt;.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;interface Person {
  personId: number;
  fullName: string;
  annualIncome: number;
}

// 👍 mark all keys as optional
const emp: Partial&amp;lt;Person&amp;gt; = {};

emp.fullName = 'Bobby Hadz';
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



</description>
      <category>typescript</category>
      <category>react</category>
      <category>webdev</category>
    </item>
    <item>
      <title>Everything about JSON Stringify Method - JavaScript</title>
      <dc:creator>Jitendra</dc:creator>
      <pubDate>Wed, 13 Sep 2023 16:27:59 +0000</pubDate>
      <link>https://forem.com/jimmy1995/json-stringify-method-javascript-5c55</link>
      <guid>https://forem.com/jimmy1995/json-stringify-method-javascript-5c55</guid>
      <description>&lt;h2&gt;
  
  
  Overview
&lt;/h2&gt;

&lt;p&gt;JavaScript provides a static method &lt;code&gt;JSON.stringify()&lt;/code&gt;. Which is useful to convert valid JavaScript object to JSON string. &lt;/p&gt;

&lt;p&gt;Apart from it this method comes with lot of flexibility to create JSON string using using its &lt;strong&gt;replacer&lt;/strong&gt; and &lt;strong&gt;space&lt;/strong&gt; arguments. &lt;/p&gt;

&lt;p&gt;In this article, we will explore how use to them.&lt;/p&gt;

&lt;p&gt;To stringify JSON data online you can use a popular online tool &lt;a href="https://www.fireboxtools.com/json-tools/json-to-string"&gt;JSON to String&lt;/a&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  Syntax
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;JSON.stringify(value, replacer, space)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Parameters of JSON.stringify
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;Value (mandatory)&lt;/li&gt;
&lt;li&gt;Replacer (optional)&lt;/li&gt;
&lt;li&gt;Space (optional)&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  1. Value Parameter
&lt;/h2&gt;

&lt;p&gt;Value is required to be passed as a parameter when calling the function.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const user = {
  "name": "Jimmy",
  "age": 67,
  "city": "New York"
};

const user_string = JSON.stringify(user);
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Output&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;`{"name":"Jimmy","age":67,"city":"New York"}`
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  2. Replacer Parameter
&lt;/h2&gt;

&lt;p&gt;Replacer is a optional parameter. It can be either an array or a function to alter the JavaScript object before converting it JSON string.&lt;/p&gt;

&lt;p&gt;Assume you have your personal information in the form of a JavaScript object and now you want to convert it to JSON string. The issue is that you don't want to include all of the keys in the JSON string. Here replacer parameter comes into picture to apply that filter. &lt;/p&gt;

&lt;p&gt;&lt;strong&gt;As an array&lt;/strong&gt;, It will contain a list of allowed keys which you want to include in the result of JSON stringify.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const user = {
    "username": "johndoe",
    "firstName": "John",
    "lastName": "Doe",
    "email": "johndoe@dev.to",
    "age": 30,
    "registrationDate": "2023-09-12T12:00:00Z"
}

const replacer = ['username', 'firstName', 'lastName'];

const userData_string = JSON.stringify(user, replacer);

console.log(userData_string); 

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Output&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;`{"username":"johndoe","firstName":"John","lastName":"Doe"}`
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;As a function&lt;/strong&gt;, It takes two parameters (Key, Value).&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;function replacer_function (key, value) {    
    // code
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Consider a case where you want to add some logic to altering JSON data (Ex - You want to stringify an object's keys that does not contain string values).&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const user = {
  "name": "John Doe",
  "age": 30,
  "email": "johndoe@example.com",
  "isSubscribed": true
}

function replacer(key, value){
    if(typeof value === 'string'){
        return undefined;
    }
    return value;
}

const user_string = JSON.stringify(user, replacer);


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Output&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;`{"age":30,"isSubscribed":true}`
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;&lt;p&gt;When replacer returns a object, string, number, boolean, or null, That returned value is treated as the value of the property, and the method converts it to a JSON string.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;When it returns function, undefined or symbol, method will skip that key and will not include in output.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  3. Space Parameter
&lt;/h2&gt;

&lt;p&gt;We can use space parameter to control spacing in final result.&lt;br&gt;
When we do not use last parameter, By default stringify method returns very crowded and dense output.   &lt;/p&gt;
&lt;h3&gt;
  
  
  Space as a Number
&lt;/h3&gt;

&lt;p&gt;When we use space as a number, the output's key-value pairs are separated by the specified number of spaces.&lt;/p&gt;

&lt;p&gt;If we discuss the Space Parameter restriction. Only 0 to 10 spacing is allowed.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const colors = {
    primary: ['red','blue','green'],
    secondary: ['cyan', 'magenta', 'yellow'],
    tertiary: ['yellow-orange', 'red-orange', 'red-purple']
}

const colors_string = JSON.stringify(colors, null, 3);
console.log(colors_string);
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Output&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;`{
   "primary": [
      "red",
      "blue",
      "green"
   ],
   "secondary": [
      "cyan",
      "magenta",
      "yellow"
   ],
   "tertiary": [
      "yellow-orange",
      "red-orange",
      "red-purple"
   ]
}`
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Space as a String
&lt;/h3&gt;

&lt;p&gt;If string is used as a space parameter. JSON stringify method will indent the result by the provided string.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const data = {
  name: "Central Park",
  city: "New York",
  country: "United States",
  amenities: ["Playgrounds", "Walking Trails", "Pond"],
};
const data_string = JSON.stringify(data, null, "fire");
console.log(data_string)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Output&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;`{
fire"name": "Central Park",
fire"city": "New York",
fire"country": "United States",
fire"amenities": [
firefire"Playgrounds",
firefire"Walking Trails",
firefire"Pond"
fire]
}`
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;I hope this was helpful to understand how JSON stringify works in JavaScript. &lt;/p&gt;

</description>
      <category>json</category>
      <category>javascript</category>
      <category>typescript</category>
    </item>
    <item>
      <title>Top 2 Strategies for Handling JSON Parse Errors</title>
      <dc:creator>Jitendra</dc:creator>
      <pubDate>Fri, 08 Sep 2023 07:32:45 +0000</pubDate>
      <link>https://forem.com/jimmy1995/top-2-strategies-for-handling-json-parse-errors-6mk</link>
      <guid>https://forem.com/jimmy1995/top-2-strategies-for-handling-json-parse-errors-6mk</guid>
      <description>&lt;p&gt;JSON is quite popular and widely used data format for client and server communication. &lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--auAnTHeJ--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/nu8nprav3cqd0x9brk9l.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--auAnTHeJ--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/nu8nprav3cqd0x9brk9l.png" alt="JSON Parse" width="800" height="450"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Why do we get a JSON parsing error and How to Resolve Them?
&lt;/h2&gt;

&lt;p&gt;If you have minor issues with JSON data. You can use any online tool such as &lt;a href="https://www.fireboxtools.com/json-tools/json-formatter"&gt;JSON formatter&lt;/a&gt;. Which provides a feature to repair broken JSON.&lt;/p&gt;

&lt;p&gt;Parsing JSON is a common task for a developer. JavaScript comes with a built-in method called &lt;a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/JSON/parse"&gt;JSON.parse()&lt;/a&gt;. Which is useful for parsing JSON string data.&lt;/p&gt;

&lt;p&gt;If JSON is valid then &lt;strong&gt;JSON.parse()&lt;/strong&gt; returns a JSON object  otherwise, it throws a SyntaxError.&lt;/p&gt;

&lt;h2&gt;
  
  
  Handle JSON Parse Error in JavaScript
&lt;/h2&gt;

&lt;p&gt;In JavaScript, There are many ways to deal with JSON parse errors, and we are going to explore two of the best here. &lt;/p&gt;

&lt;h2&gt;
  
  
  1. Handle Using try-catch block
&lt;/h2&gt;

&lt;p&gt;To deal with JSON parse errors, the try-catch block method is most commonly used in JavaScript.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;try {
  const json = '{"name": "Jimmy", "age":28}';
  const obj = JSON.parse(json);
  console.log(obj.name);
  // expected output: "Jimmy"
  console.log(obj.age);
  // expected output: 28
} catch (e) {
  console.log(e);
  // expected output: SyntaxError: Unexpected token o in JSON at position 1
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  2. Handle Using if-else block
&lt;/h2&gt;

&lt;p&gt;Another useful method for handling JSON parse errors is to use an if-else block.&lt;br&gt;
The use of this approach helps when you are doing other tasks in try-catch (for example, API requests and other processing) and then parsing JSON. Using this approach, you may find errors caused by SyntaxError.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;try {
    // API calls
    // other handling
    const json = '{"name":"Jimmy", "age:42}';
    const obj = JSON.parse(json);
} catch (error) {
    if (error instanceof SyntaxError) {
        console.log(error);
        // expected output: SyntaxError: Unexpected token o in JSON at position 1
    }
}

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



</description>
      <category>programming</category>
      <category>javascript</category>
      <category>typescript</category>
      <category>json</category>
    </item>
    <item>
      <title>What makes Go's compiler so FAST?</title>
      <dc:creator>Jitendra</dc:creator>
      <pubDate>Thu, 07 Sep 2023 14:26:05 +0000</pubDate>
      <link>https://forem.com/jimmy1995/what-makes-gos-compiler-so-fast-7f3</link>
      <guid>https://forem.com/jimmy1995/what-makes-gos-compiler-so-fast-7f3</guid>
      <description>&lt;p&gt;One of the best features of Go is its extremely quick compiler.&lt;br&gt;
However, what exactly did the Go team do to achieve this?&lt;br&gt;
Why is the Go compiler so fast?&lt;br&gt;
Here are the reasons.&lt;/p&gt;

&lt;h2&gt;
  
  
  Go is simple
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Go only has 20-something keywords in the language.&lt;/li&gt;
&lt;li&gt;Compared to Java in the 60s and close to 100 for C++, for example.&lt;/li&gt;
&lt;li&gt;This helps with shortening the compilation time.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  No unused components
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;You can't compile with unused components like variables or imports.&lt;/li&gt;
&lt;li&gt;Your IDE or code editor will also constantly complain during your development.&lt;/li&gt;
&lt;li&gt;This helps reduce unnecessary instructions to compile at the end.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  No symbol table when parsing
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;A symbol table is a data structure for storing entities like variable/function names.&lt;/li&gt;
&lt;li&gt;Parsing in languages like C/C++ requires the symbol table.&lt;/li&gt;
&lt;li&gt;Note that the symbol table is still used for full compilation, just not during parsing in Go, which reduces part of compilation time.
No header files.&lt;/li&gt;
&lt;li&gt;C/C++ uses header files to connect the different components together.&lt;/li&gt;
&lt;li&gt;These header files take extra time to load, parse then compile.&lt;/li&gt;
&lt;li&gt;Go, on the other hand, doesn't use header files.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Prioritisation
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Fast compilation speed has been the priority since the birth of Go.&lt;/li&gt;
&lt;li&gt;As a result, other features of Go have to be designed with fast compilation in mind.&lt;/li&gt;
&lt;li&gt;Such prioritisation makes a difference, especially over time.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Hope this helps you get some ideas on this subject!&lt;/p&gt;

</description>
      <category>go</category>
      <category>programming</category>
      <category>computerscience</category>
    </item>
    <item>
      <title>Encode URL in Javascript</title>
      <dc:creator>Jitendra</dc:creator>
      <pubDate>Tue, 05 Sep 2023 11:26:33 +0000</pubDate>
      <link>https://forem.com/jimmy1995/encode-url-in-javascript-2j72</link>
      <guid>https://forem.com/jimmy1995/encode-url-in-javascript-2j72</guid>
      <description>&lt;p&gt;Did you know that each website and online resource has a unique URL for its address? Uniform Resource Locators, or URLs, can appear straightforward but contain numerous components and special characters, making them truly fairly complex.&lt;/p&gt;

&lt;h2&gt;
  
  
  Built-in JavaScript Encoding Functions
&lt;/h2&gt;

&lt;p&gt;When It comes to encoding in JavaScript. It Gives to two functions to perform encoding &lt;strong&gt;encodeURIComponent()&lt;/strong&gt; and &lt;strong&gt;encodeURI()&lt;/strong&gt;.&lt;/p&gt;

&lt;h3&gt;
  
  
  How to use encodeURI in JavaScript
&lt;/h3&gt;

&lt;p&gt;This function is used for encoding the complete URI (Uniform Resource Identifier). A limitation of we can say feature of &lt;strong&gt;encodeURI&lt;/strong&gt; is that it does not encode characters &lt;code&gt;~!@#$&amp;amp;*()=:/,;?+'&lt;/code&gt; .&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Syntax:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const originalURI = "https://www.dev.to/search?q=Hello dev";
const encodedURI = encodeURI(originalURI);
console.log(encodedURI);
VM249:3 https://www.dev.to/search?q=Hello%20dev

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  How to use encodeURIComponent in JavaScript
&lt;/h3&gt;

&lt;p&gt;This function is used to encode complete URL (Uniform Resource Locator) instead of URI. &lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Syntax:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const originalURI = "https://www.dev.to/search?q=Hello dev";
const encodedURI = encodeURIComponent(originalURI);
console.log(encodedURI);
VM261:3 https%3A%2F%2Fwww.dev.to%2Fsearch%3Fq%3DHello%20dev
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You can use any online JavaScript code executor, browser console, or online &lt;a href="https://www.fireboxtools.com/encoding-decoding-tools/url-encoder" rel="noopener noreferrer"&gt;URL encoder&lt;/a&gt; tool to verify your encoding output.   &lt;/p&gt;

&lt;h3&gt;
  
  
  Encoding vs Encryption
&lt;/h3&gt;

&lt;p&gt;People frequently get confused between encoding and encryption. Although both are used to transform data but to serve different purposes and requirements. &lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Encoding:&lt;/strong&gt; Encoding is used to transform data into specific format without maintaining security. It is easily reversible using appropriate method. &lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Encryption:&lt;/strong&gt;: Encryption is used to protect data using  complex algorithms. It ensures data confidentiality and security. Encrypted data is also reversible but only with the correct decryption key. &lt;/p&gt;

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