teleren/devto huggingface dataset:
Optional Chaining In JavaScript
Published: 2021-04-08 07:14:07

---
title: Optional Chaining In JavaScript
published: true
date: 2021-04-07 08:44:56 UTC
tags: 
canonical_url: https://giftegwuenu.com/optional-chaining-in-java-script/
---

Are you always frustrated when you try to access a value from an object/array and it returns this error `Uncaught TypeError: Cannot read property 'value' of undefined` because the value is not available yet or does not exist? Let's see an example, say we have `countries` object with values like this:

```js
countries = {
  name: 'Nigeria',
  region: 'Africa',
  population: 186988000,
  currency: {
    code: 'NGN',
    name: 'Nigerian Naira',
    symbol: '₦',
  }
};
```

and we try to return a value that is not yet available or doesn't exist yet:

```js
console.log(countries.languages.name);
```

we will get back an error from the browser that the value is undefined. How do we tackle this problem? we can validate that each reference in the nested property is available with an expression like this:

```js
console.log(countries.languages && countries.languages.name);
```

Now, this won't throw an error and will return `undefined` if a value doesn't exist. To avoid doing that extra step of validating we can use a different method - **Optional Chaining**.

### Introducing the Optional Chaining Operator

The JavaScript Optional Chaining Operator is a native feature introduced in ES2020 that allows you to safely access deeply nested properties of an object without having to check for the existence of each of them. 

Optional Chaining uses the `?.` operator to access the properties of objects. The usage of the `?.` operator is similar to the typical `.` operator, but when a reference is `undefined` or `null`, rather than throwing an error, it would return `undefined`. 

The syntax for optional chaining can be used in any of the following positions:

```js
obj?.prop       // optional static property access
obj?.[expr]     // optional dynamic property access
func?.(...args) // optional function or method call
```

In our previous example, we can then change the expression to this:

```js
console.log(countries?.languages?.name);
```

This will check if the parent value exists and if it doesn't it returns `undefined`. Optional chaining can be used often when we are fetching responses from an API we may not be 100% sure if a certain object exists in our API response.

### Browser Support

The Optional Chaining Operator is currently supported in all browsers except Internet Explorer as seen from [CanIUse](https://caniuse.com/?search=optional%20chaining).

![Can I use - Optional Chaining](https://giftegwuenu.com/images/uploads/mdn-javascript__operators__optional_chaining-1617785356676.png)

## Resources

* MDN Resource: <https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Optional_chaining>
* TC39 Proposal Optional Chaining: <https://github.com/tc39/proposal-optional-chaining>

## Video Format
{% youtube u29ZiZnR-q0 %}
Architecture tests with ArchUnit, pt. 3: Advanced stuff
Tags: architecture, java, testdev, android
Published: 2021-04-07 08:39:52

​​​ArchUnit has many tricks up to its sleeve. We’ve already seen how to check package structure, language elements such as classes, fields, and methods, and how to make sure your layered architecture is sound. But there’s more! Let’s take a look at some advanced conce​pts.

Slicing and dicing
As we’ve seen in the previous part of this series, ArchUnit makes it easy to test layers and their relationships. However, dividing your codebase only horizontally isn’t enough—in all but very tiny projects, you’d end up with huge layers containing too many unrelated classes. Thus we need to divide our code vertically as well, usually by user-facing features and project-specific or general-purpose libraries. Those features or libraries are often compilation units (e.g., Gradle modules), but that doesn’t need to concern us at this moment...
Lila is a GPT-3 powered bot who loves to ponder about life.
Published: 2021-04-07 08:39:27

👋🏻 Hi guys,

My new side project is live! 🎉
lila.mytinyai.com

Lila is a GPT-3 powered bot who loves to ponder about life. You can help train her by liking the quotes you find meaningful, humorous, or resonate with. Each week, the top quotes will be fed back into the AI, allowing it to learn and improve upon itself.

🧠 quotes are 100% generated using OpenAI's GPT-3 engine
✌🏻 frontend with Vuejs & Vitejs & Tailwindcss
📚 quick & easy backend using Supabase_io
📃 auto-deploy from Github via Cloudflare Pages
The past and the future of Android R class
Tags: android, gradle
Published: 2021-04-07 08:37:49

Every Android application contains some resources like localized strings, icons, screen layouts, or navigation targets. And every native Android application accesses these resources using Android’s retrieval mechanism based on resource IDs listed in R class. Let’s deep dive into the world of almighty R to see whether there are any gotchas or possible improvements. Spoiler alert: There are!

What is a R class? (link in bio)
How We Developed a Notes App
Tags: security, ios, discuss
Published: 2021-04-07 08:36:31

We have developed a notes app that is suitable for every person for personal use and for teamwork. Dusfer helps you be more efficient, productive and successful.

▫️  the most necessary sections for everyday life
▫️  templates for notes and tasks
▫️  you can archive, pin, add tags to notes and tasks
▫️  calendar management is synchronized with the standard iOS and Google Calendars
▫️  all your tasks from other services - Trello, Asana, Jira, Booking, Aviasales, AirBnb, etc. will transfer in a convenient form to Dusfer
▫️  to enter the application, you set a 6-digit pin code that can be linked to Face ID or Touch ID.
▫️  you can export your notes and tasks to PDF, DOCX, HTML, TXT
▫️  you can add people to notes or tasks.

Dusfer does not have access to your data, it is stored encrypted on the most reliable European servers.

Try Dusfer 👉🏻 https://apps.apple.com/ru/app/dusfer-%D0%B7%D0%B0%D0%BC%D0%B5%D1%82%D0%BA%D0%B8-%D0%B8-%D0%B7%D0%B0%D0%B4%D0%B0%D1%87%D0%B8/id1539406924
Architecture tests with ArchUnit, pt. 2: Rules
Tags: architecture, java, testdev, android
Published: 2021-04-07 08:35:54

In the first part of this series, we’ve had a glimpse of an architecture test written with the almighty ArchUnit, but of course there’s much more! Although ArchUnit’s API looks like Java Reflection API, it also contains powerful constructs to describe dependencies between code or predefined rules for testing popular architecture styles. Let’s see what we’ve got to play with!

First things first... (link in bio)
How to Get Your First Job as a Go Developer
Tags: go
Published: 2021-04-07 08:31:48

## How to Get Your First Job as a Go Developer

If you are reading this, then I assume you want to work as a go developer. Perhaps you want to build the next cool thing in cloud computing and mobile, or perhaps you just want to write software that will help a small business reshape its operations. Whatever the reason, there are Go opportunities.

One of the hardest parts of learning to program is figuring out how to get your first job as a developer. This guide is for total beginners who know a little bit about programming and now are looking for the next step.
Introduction

When I started learning to program, I had a great time. But when I realized that I actually wanted to do it for a living, I was suddenly overwhelmed with everything I needed to know. Where do I start? What should I learn? How long will it take me?

I’ll also assume that you have no experience with Go whatsoever, so it will be even more valuable for you if you have no previous programming experience whatsoever.

These days there are many high-quality websites, books, and videos that are a great introduction to programming in general.

The stuff below is focused on Go development, mostly because that’s what I know. But if you want a broader introduction to programming in general, try browsing around communities like dev.to, reddit etc.

## How to get hired as Go developer

There are two main ways to get your first job as a Go developer:

* Option 1: Teach yourself how to program Go.
* Option 2: Get hired as an intern.

The first option is hard and time consuming and the second option is easier, but you need to know how to write Go.

The [go-language](https://golang.org/doc/tutorial/) website and documentation have great tutorials, but they start off very basic. You can find some more Go tutorials like this [tutorial](https://golangr.com/) and this [one](https://www.digitalocean.com/community/tutorials/how-to-build-and-install-go-programs)

This tutorial holds your hand and shows you all the details you need to get started with Go.
Architecture tests with ArchUnit, pt. 1: Reasons

Tags: architecture, java, testdev, android
Published: 2021-04-07 08:31:47

Good architecture is essential for a codebase to enjoy a long and happy life (the other crucial ingredient is running automated unit tests, but that’s a different blog post). Nowadays there are many sensible options, including our favorite for mobile apps, Clean arch, but no matter which one you choose, you’ll need to document and enforce it somehow.

The former is traditionally accomplished by some form of oral history passed from one developer to another (sometimes augmented by blurry photos of frantically scribbled whiteboard diagrams), while the latter is sporadically checked during code reviews (if there’s time—which there isn’t—and you remember all the rules yourself—which you don’t).

Or maybe you even have a set of gradually outdated wiki pages and fancy UML models created in some expensive enterprise tool. Or complicated but incomplete rules written for rather arcane static analysis frameworks. Or any other form of checks and docs, which are usually hard to change, detached from the actual code, and difficult and rather expensive to maintain.

But fret not! There is a new architectural sheriff in this JVM town of ours and he’s going to take care of all of this—say hello to your new best friend, ArchUnit!

What’s all the fuss about?...
Hosting Static Websites on Heroku
Tags: javascript, heroku, php
Published: 2021-04-07 08:28:33

Hey there, so I've been developing React web-apps for a year now, but recently I've decided to go for the good old method of web development **DOM**.

So I took up an Udemy course by Brad Traversy to create 50 projects solely based on HTML, CSS and JS.

After I've created my first project it hit to that I had no idea on how to host an static website for free, I know github gives us this option but I've worked with Heroku so much that I wanted nothing more that to use it here as well, and after some googling I've found some outdated-solution.
I decided to write an clean solution here.

### So Here comes the good part.

[Sites Hosted Here](https://onepiece-cards.herokuapp.com)
[Code Here](https://github.com/tsankesara/50Days-Project-Challange/tree/main/ExpandingCards)

So as Heroku doesn't allow us to host serve static content I'll be using php to host it.

**Step 1 =>** Create an index.php file in your root directory.
**Step 2 =>** Insert Following Code (Where index.html in you main html file)

````
<?php 
define('PROJECT_ROOT_PATH', __DIR__);

include_once(PROJECT_ROOT_PATH . '/index.html'); 
?>
```` 

**Step 3 =>** Create an composer.json file in root and fill it wil `{}` (php server require an composer.json file, it can be an empty json but it is still required)

**Step 4 =>** Run following commend to create and commit an local git repository 
`git init`
`git add .`
`git commit -m 'first commit'`

**Step 5 =>** Create an [Heroku Account](https://signup.heroku.com/) and Install [Heroku Cli](https://devcenter.heroku.com/articles/heroku-cli).

**Step 6 =>** Run `heroku login` on you cmd or terminal.

**Step 7 =>** Run `heroku apps:create <APP_NAME>`

**Step 8 =>** Run `git push heroku <BRANCH_NAME>`

### So it concludes us deploying static websites on Heroku. 

*Please leave an comment if this helped or if you faced any issues, I'd be more then happy to help you. Follow me if you liked this content I'd be making post on daily bases about my journey through making these 50 projects.*
Login without username in TTY
Tags: linux, authentication, tutorial
Published: 2021-04-07 07:25:41

# Login WITHOUT Username from TTY

Hi, in this blog post, i will showcase how you can configure your getty systemd service so that, you are able to login without entering your username. This is really helpful if you are the only one that uses the system. If multiple people use your system, you can still use this method by assiging each "person" a seperate tty to login to the computer.

> This method has been tested on Arch Linux. (systemd)

![Default login prompt in tty][1]

## Enabling auto login with username in all TTY

First, you need to edit the `getty@tty1.service` file.

`sudo vim /etc/systemd/system/getty.target.wants/getty@tty1.service` (if you do not know how to use vim, use nano or any other editor)

Check for the line which starts with `ExecStart=` and replace it with `ExecStart=-/sbin/agetty -n -o <username> %I`
Make sure to change `<username>` to which ever username you want as the default.

![Changing configuration file][2]

## Enabling auto login for a specific TTY

Instead of editing `getty@tty1.service`, you edit the file for the tty you want. ie, `getty2.service` for example

## Working

Now you should be able to see a prompt like this when you reboot

![New prompt with only password][3]

Source: [getty#Prompt_only_the_password_for_a_default_user_in_virtual_console_login](https://wiki.archlinux.org/index.php/getty#Prompt_only_the_password_for_a_default_user_in_virtual_console_login)
For more info on [how tty's work](http://www.linusakesson.net/programming/tty/)

## AUTHOR
DevHyperCoder 

[Website](https://devhypercoder.com) | [GitHub](https://github.com/DevHyperCoder) | [Youtube](https://www.youtube.com/channel/UCc-2z5AEBmBcqzyzn4dN_cg) | [Patroen](https://www.patreon.com/DevHyperCoder) | [Discord](https://discord.gg/X9AgMg2cBd)

[1]: https://images.devhypercoder.com/blog/login_without_username_arch/login_prompt.png
[2]: https://images.devhypercoder.com/blog/login_without_username_arch/login_without_username.png
[3]: https://images.devhypercoder.com/blog/login_without_username_arch/onlypass.png
How to create a Personal Access Token - Azure DevOps
Tags: azuredevops, devops, pat, codenewbie
Published: 2021-04-07 07:55:21

Today I'm going to show you exactly what to do to create a __Personal Access Token in Azure DevOps__.

After the [article](https://dev.to/n3wt0n/how-to-create-a-personal-access-token-pg7) and the [video](https://youtu.be/SzrETQdGzBM) of a couple of weeks ago about the creation of Personal Access Tokens in GitHub, today I have for you a step by step guide on how to __create a PAT in Azure DevOps__.

### Intro

As we have seen in the other article and video I've mentioned before, Personal access tokens (PATs) are an alternative to using passwords for authentication when using APIs or the command line, or if we want to integrate with any 3rd party system.

Let's see how we can create a PAT in Azure DevOps

### Video

To see how to __create a PAT__ on your Azure DevOps, and how to properly scope it, I've created a video in which I explain __step by step__ what you need to do.

Here you have it, enjoy the watch!

{% youtube o1rrrVKzc-o %}

[Link to the video: https://youtu.be/o1rrrVKzc-o](https://youtu.be/o1rrrVKzc-o)

### Conclusions

As you have seen, creating a PAT in Azure DevOps is slightly faster than doing it in GitHub, but the process is anyway very similar.

Let me know in the comment section below if you have any question about PATs in Azure DevOps.

__Like, share and follow me__ 🚀 for more content:

📽 [YouTube](https://www.youtube.com/CoderDave)
☕ [Buy me a coffee](https://buymeacoffee.com/CoderDave)
💖 [Patreon](https://patreon.com/CoderDave)
👕 [Merch](https://geni.us/cdmerch)
👦🏻 [Facebook page](https://www.facebook.com/CoderDaveYT)
🐱‍💻 [GitHub](https://github.com/n3wt0n)
👲🏻 [Twitter](https://www.twitter.com/davide.benvegnu)
👴🏻 [LinkedIn](https://www.linkedin.com/in/davidebenvegnu/)
🔉 [Podcast](https://geni.us/cdpodcast)

{% youtube o1rrrVKzc-o %}
Functional Components in React
Tags: todayilearned, react, javascript
Published: 2021-04-07 07:50:29

I started learning React yesterday and hence I thought I'll write articles about what I learned each day. 

### What are components in React?
**Short answer:** Components are independent and reusable block of code and return html using render() function.

Suppose we have the following UI: 
![Explaining react components via UI layout](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/rm49x608ph5pxvbdl5iy.png) 

So we will have components for each like Navbar component, sidebar component, component for article and footer. 

React allows us to write components in two ways:
- Functional components
- Class Components


### Writing your first React component

```jsx
<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>Functional Components in React</title>
</head>

<body>
<div id="root"></div>

// Babel (To render JSX), React and ReactDOM
<script src="https://unpkg.com/@babel/standalone/babel.js"></script>
<script src="https://unpkg.com/react/umd/react.development.js"></script>
<script src="https://unpkg.com/react-dom/umd/react-dom.development.js"></script>

<script type="text/babel">
  function SayHello(){
    return (<h1>Hello, World!</h1>);
  };

  ReactDOM.render(
      <SayHello />,
      document.getElementById('root')
  );
</script>
</body>
</html>
```

#### Understanding above code: 
We have a simple html document with div with id as root and some script files: 
- Babel (used to render jsx)
- React and ReactDOM

In our inline script, we wrote our first functional component.
Function SayHello() returns jsx and thus we used imported babel.

Now, we render this JSX into out html with the help of render() function from ReactDOM. 
render() accepts two arguments: `render(WHAT TO RENDER, WHERE TO RENDER)`.

Hence our functional component SayHello() renders `Hello, World!` into the div with id as `root`.

#### Points to remember: 
1. Start component name with CAPITAL letter. (Capital CamelCase is preferred)
2. Your component cannot return multiple elements. Therefore make sure to bind all of them into a single parent element. e.g.
```html
<div>
 <h1></h1>
 <p></p>
</div>
``` 

Okay, that's all today. Hope you liked the article and would also like to hear from you to improve my ways of writing these articles. 
Don't forget: I'm Noob writer after all :grin:


Some Links to learn React: 
- [React Official Website](https://www.reactjs.org/)
- [FreeCodeCamp](https://www.youtube.com/watch?v=DLX62G4lc44)
- [EggHead.io React Beginner's Free Course](https://egghead.io/courses/the-beginner-s-guide-to-react)
Nipo in memory database with go
Tags: go
Published: 2021-04-07 07:37:19

Nipo is a powerful, fast, multi-thread, clustered and in-memory key-value database, with ability to configure token and acl on commands and key-regexes written by GO. With several mathematical and aggregation functionalities on batch of keys and values.

##Fast

Nipo will give you up to 15K OPS in single mode and up to 2.5K OPS in cluster mode with 2 slaves.

##Multi-Thread

Nipo's architecture is multi-thread and you can define core and threads in your config file.

##Clustered

Nipo supports several slaves and guaranties your slaves synchronization. It will automatically sync slave after comming up. You can ask your cluster status. The healthcheck interval could be configured in millisecond.

##In-Memory

Nipo is in-memory database and data will be lost if service stops.

 {% github NipoDB/nipo %}
Unemployment In India 2021 - Effects On Employment Sector Due To Covid-19 Pandemic In Indian
Published: 2021-04-07 07:29:00

find latest [Indian government jobs](https://www.jobkari.com) We provide you latest government jobs. You can also able to access State Government & Central Governments, Online Form, Online Registration, Result Download, Answer Key, Board Exams, Latest Results, Admit Card, Sarkari Exam’s Syllabus, Bank Exams results etc. We always try to update our website hourly to provide you the Best latest information.

[https://www.jobkari.com](https://www.jobkari.com)
Using serial console to connect to VMs
Published: 2021-04-07 07:20:04

Working with virtual machines in the public cloud, requires us from time to time to troubleshoot operating system, boot, and network connectivity issues.

In the past, when we worked locally with physical machines, we were able to login to the server console and run commands that assisted us debug problems, but how do we accomplish the same using public clouds?

The cloud providers allow us to connect to a “serial console”, login to the operating system and run commands.

Below are the various alternatives for connecting to a serial console:
![Alt Text](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/2jgx7p2i0le71emkz94r.JPG)

### Additional references

* [EC2 Serial Console for Linux instances](https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/ec2-serial-console.html)
* [Troubleshoot Boot and Networking Issues with New EC2 Serial Console](https://aws.amazon.com/blogs/aws/troubleshoot-boot-and-networking-issues-with-new-ec2-serial-console/)
* [Azure Serial Console for Windows](https://docs.microsoft.com/en-us/troubleshoot/azure/virtual-machines/serial-console-windows)
* [Azure Serial Console for Linux](https://docs.microsoft.com/en-us/troubleshoot/azure/virtual-machines/serial-console-linux)
* [Serial console with Azure VMs - Troubleshooting and diagnosing](https://microsoft.github.io/AzureTipsAndTricks/blog/tip191.html)
* [Interacting with the serial console](https://cloud.google.com/compute/docs/instances/interacting-with-serial-console)
* [Viewing serial port output](https://cloud.google.com/compute/docs/instances/viewing-serial-port-output)
* [gcloud compute connect-to-serial-port](https://cloud.google.com/sdk/gcloud/reference/compute/connect-to-serial-port)
* [Troubleshooting Instances Using Instance Console Connections](https://docs.oracle.com/en-us/iaas/Content/Compute/References/serialconsole.htm)