teleren/devto huggingface dataset:
Embrace the Power of Nullish Coalescing Operator (??) in JavaScript/TypeScript
Tags: javascript, typescript, programming
Published: 2023-08-01 10:14:09

---
title: "Embrace the Power of Nullish Coalescing Operator (??) in JavaScript/TypeScript"
published: true
description: "Learn how to use the Nullish Coalescing Operator, a powerful tool in JavaScript and TypeScript."
tags: JavaScript, TypeScript, Programming
---

## Introduction

JavaScript and its superset, TypeScript, provide us with many tools to make our daily development tasks easier and our code more concise. One such tool is the **Nullish Coalescing Operator** (`??`). In this post, I'll walk you through how to use it and why it's so powerful.

## What is the Nullish Coalescing Operator?

The Nullish Coalescing Operator (`??`) returns its right-hand side operand when its left-hand side operand is `null` or `undefined`, and otherwise returns its left-hand side operand.

## Examples of Using the Nullish Coalescing Operator

Here are some examples of using the Nullish Coalescing Operator in JavaScript/TypeScript:

```javascript
let x = null;
let y = x ?? "default";
console.log(y);  // "default"
```

In this example, `x` is `null`, so `y` becomes `"default"`.

Another example:

```javascript
let x = "Hello, world!";
let y = x ?? "default";
console.log(y);  // "Hello, world!"
```

In this example, `x` is not `null` or `undefined`, so `y` becomes `x` which is `"Hello, world!"`.

## Nullish Coalescing Operator vs OR Operator

The OR operator (`||`) in JavaScript also behaves similarly, but it returns the right-hand side operand if the left-hand side operand is `falsy` (`false`, `0`, `""`, `null`, `undefined`, `NaN`). This is an important difference from the Nullish Coalescing Operator. Let's see it in the examples below:

```javascript
let x = "";
let y = x || "default";
console.log(y);  // "default"
```

In this example, `x` is `""` (falsy), so `y` becomes `"default"`.

But with the Nullish Coalescing Operator:

```javascript
let x = "";
let y = x ?? "default";
console.log(y);  // ""
```

In this example, `x` is not `null` or `undefined`, so `y` becomes `x` which is `""`.

So, the Nullish Coalescing Operator is specialized for checking `null` or `undefined`, allowing us to avoid the problem of the OR operator replacing valid values like `0` or `""` (empty string) with default values.

## Conclusion

The Nullish Coalescing Operator (`??`) is a powerful tool in JavaScript and TypeScript development. You can use this operator to keep your code concise when setting default values for potentially non-existent values. Also, understanding the difference from the OR operator (`||`) allows you to use the Nullish Coalescing Operator more appropriately.

That's all for the tutorial on how to use the Nullish Coalescing Operator in JavaScript/TypeScript. I hope this post helps your development even a little. I'd appreciate it if you could give a like or share. Happy coding!
Building a frontend auth in WordPress
Tags: webdev, wordpress, php, tutorial
Published: 2023-08-01 10:06:02

WordPress, love it or hate it, is here to stay. It powers ~65% of the Internet, and is used by corporations large and small, bloggers, agencies and everything in between.

As WordPress website's grow in functionality it often becomes necessary for users to log into the site. One example of this may be when you offer (pay)walled content, whereby a user must be logged in to read it.

There are plugins that can do this, but that's a heavy dependency on a third-party that can introduce security risks, not to mention a risk of them disappearing (this happens more often than you may think, even for popular plugins).

So, roll your own.

We've created a series of tutorials on [how to build your own frontend auth experience in WordPress](https://accreditly.io/articles/create-a-frontend-auth-experience-in-wordpress).

This series of articles takes you through the following:

1. [Building a frontend registration form in WordPress](https://accreditly.io/articles/building-a-frontend-registration-form-in-wordpress)
2. [Building a frontend login form in WordPress](https://accreditly.io/articles/creating-a-frontend-login-form-in-wordpress)
3. [Building a frontend forgotten password form in WordPress](https://accreditly.io/articles/building-a-frontend-forgotten-password-form-in-wordpress)

Check it out, and if you have any questions let us know in the comments.
How to custom hooks get state after setState
Tags: react
Published: 2023-08-01 08:47:29

`jsx
const useCustomState = () => [value, setValue];
const [data, setData] = useCustomState(initValue);
useEffect(() => {
   const fn = async() => {
       await setData(1);
       console.log(data); // ouput 1
   };
   fn();
}, [])
`
How to implement this custom hooks function can get the latest value of data immediately after setting data in async syntax. I know it should be done by useEffect(() => console.log(data), [data]). But the useEffect all over the floor looks very inelegant
Sap fico training in Chennai
Tags: webdev, beginners, javascript, tutorial
Published: 2023-08-01 08:08:37

[Sap fico training in Chennai.](https://intellimindz.com/sap-fico-training-in-chennai/)
That's great to hear that IntelliMindz offers SAP FICO training in Chennai. SAP FICO is indeed a highly sought-after skill in the IT industry, and obtaining certification in this field can be beneficial for career growth. The course provided by IntelliMindz covers various aspects of SAP FICO, which is an important module in SAP ERP.

SAP FICO is primarily used for financial reporting, both internally and externally, within an organization. It involves recording business transactions and generating financial statements. The term "SAP FICO" is derived from the combination of "FI" (financial accounting) and "CO" (controlling). By enrolling in the SAP FICO training at IntelliMindz, you can learn about the functionalities and operations of SAP FICO, which are crucial for managing financial processes in enterprises.

Obtaining knowledge and skills in SAP FICO can enhance your job prospects, particularly in multinational companies (MNCs) where SAP is widely implemented. Completing the SAP FICO course and receiving certification will provide you with a competitive edge in the job market.

If you're interested in enrolling in the SAP FICO training program at IntelliMindz, I recommend reaching out to them directly for further details regarding the course curriculum, duration, fees, and enrollment process.
Link in bio
Published: 2023-08-01 07:50:51

It felt like forever for me finish to assignment, however to see the end result was really rewarding to see. At first I assumed that I would have to create a new file with just the style.css but it looks like I didn't have to! If anyone has any feedback please let me know. My link will be below: 

https://truex71.github.io/trux71-1.github.io/
What's your favorite use case for NFTs
Tags: nft, web3, blockchain, dapp
Published: 2023-08-01 07:44:16

Non-Fungible Tokens (NFTs) have taken the world by storm, finding applications across various domains including art, gaming, real estate, and more. These unique digital tokens allow for verifiable ownership of unique digital assets. What fascinates you most about NFTs? What's your favorite use case or the area where you think NFTs shine the most? Join this discussion to explore the most intriguing applications of NFTs and share your thoughts and experiences with like-minded enthusiasts!
Excel Pivot Đếm số lượng item không trùng nhau (distinct count)
Published: 2023-08-01 07:31:24

Có thể các bạn đã biết, Excel Pivot là 1 tính năng cực kỳ hữu ích giúp chúng ta thực hiện việc "phân tích dữ liệu" 
vấn đề là khi phân tích dữ liệu, thường sẽ cần "đếm số lượng giá trị không trùng nhau" 

nhưng dùng Excel Pivot Table bình thường thì không có 

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/koc60s667cnhff5l60b5.png)

để dùng dc tính năng "đếm số lượng item không trùng nhau" này, lúc insert pivot table, hãy chọn thêm "Add this data to Data Model" 

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/7jpfc4gek5rw5irdia0o.png)

Lúc này, khi Value Field Setting sẽ thấy Distinct Count xuất hiện 


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/c1i3xjrgwnwri0oirts2.png)

ngoài ra còn nhiều trò khác, như tạo cột phụ, có thể xem thêm ở [đây](https://trumpexcel.com/count-distinct-pivot-table/)
AIAST – An advanced IAST SaaS platform, see the article at https://dev.to/zeroday
Published: 2023-08-01 07:27:43

That's great to hear!

The AIAST of ZeroDay sounds like a powerful tool for application security testing. With its cloud-based platform, it provides convenience and accessibility for security teams. Its Interactive Application Security Testing (IAST) capabilities allow for the detection and remediation of vulnerabilities in applications. This can be really helpful in ensuring that your applications are secure and protected against potential threats.

As for the additional information, It seems that the article on the Dev Community profile of Zeroday Co., Ltd. highlights AIAST as an advanced interactive application security tool. This tool is designed to identify vulnerabilities in both self-developed code and open-source dependencies. It's interesting to learn that AIAST is offered as a SaaS platform, which can provide convenience and ease of use for users. If you want to learn more about AIAST and its capabilities, I recommend checking out the article on their Dev Community profile at the following link: Zeroday Co., Ltd. — DEV Community Profile.


If you're interested in having a deeper view of how our IAST platform tool (AIAST) can secure your projects from open-source risks, currently, we are offering a free demo online, and welcome any partners to cooperate with us, please contact me and sign up for getting free AIAST demos:

•Email: gilbert@zeroday.co.uk
•Play Hard, Work Smart

https://www.linkedin.com/in/zeroday-aiast-saas-platform-gilbert/
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/02ucl57mf9hhxc2borci.jpg)
Create an OS User in Linux
Published: 2023-08-01 07:12:09

```
# Create a linux user
> sudo adduser <name> --home /home/<name>
> sudo usermod -aG sudo <username>
```

1. 

```
adduser 
```
command create an user in Linux OS but without sudo permission.

2. 

```
usermod 
```
add the user to specific OS group, in this case the group is sudo.
用Kind 安装k8s和k8s dashboard
Published: 2023-08-01 07:06:05

- 1、 Install Kind and kubctl (安装Kind和kubctl) [参考官网的教程] (https:kind.sigs.k8s.io/docs/)

---

- 2、 创建指定端口的集群
  - 2.1 编辑配置文件 'kind-example-config.yaml'
    ```
kind: Cluster
apiVersion: kind.x-k8s.io/v1alpha4
networking:
  # WARNING: It is _strongly_ recommended that you keep this the default
  # (127.0.0.1) for security reasons. However it is possible to change this.
  apiServerAddress: "0.0.0.0"
  # By default the API server listens on a random open port.
  # You may choose a specific port but probably don't need to in most cases.
  # Using a random port makes it easier to spin up multiple clusters.
  apiServerPort: 6443
nodes:
  - role: control-plane
    extraPortMappings:
    - containerPort: 30001
      hostPort: 30001
      listenAddress: "0.0.0.0"
      protocol: tcp
    - containerPort: 30002
      hostPort: 30002
      listenAddress: "0.0.0.0"
      protocol: tcp
    - containerPort: 30003
      hostPort: 30003
      listenAddress: "0.0.0.0"
      protocol: tcp
    - containerPort: 30004
      hostPort: 30004
      listenAddress: "0.0.0.0"
      protocol: tcp
    - containerPort: 30005
      hostPort: 30005
      listenAddress: "0.0.0.0"
      protocol: tcp


    ```
  - 2.2 根据配置文件创建集群
    ```
kind create cluster --config kind-example-config.yaml --name mycluster
    ```

---

- 3、安装k8s dashboard
  - 3.1 下载配置文件
    ```
wget https://raw.githubusercontent.com/kubernetes/dashboard/v2.7.0/aio/deploy/recommended.yaml
    ```
  - 3.2 编辑配置文件

    ![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ym377gq3f0fjhcwgvsq6.png)

  - 3.3 根据配置文件执行安装
    ```
kubectl apply -f recommended.yaml
    ```

---

- 4、校验dashboard是否拉起
```
kubectl get deployments -n kubernetes-dashboard
```
  
![说明没毛病](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/lzph82dq33w9uk46o2em.png)

---

- 5、校验端口是否启用 `netstat -tlnp`
  > 能够看到30001端口在用，就是没毛病的
  ![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/hmg2ezs6ict7m0dxbcp2.png)

---

- 6、访问dashboard地址  https://www.xxx.top/k8s
  > 能够到达这一步，就说明上面流程都没有问题
  ![能够到达这一步，就说明上面流程都没有问题](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/klyhl2qkchenzlnjr7nv.png)

---

- 7、生成token [参考官方文档](https://github.com/kubernetes/dashboard/blob/master/docs/user/access-control/creating-sample-user.md)

- 8、登录态过期时间优化（默认15分钟）
  > 需要说明的是，登录态过期时间不是token过期时间，按照第7步生成的token是永久有效的，网上都说成了token过期时间，有歧义！
  > [修改流程参考](https://www.cnblogs.com/xiaochina/p/12973241.html) 其中的`43200` 这个参数表示43200秒，也就是12小时；
修改完配置后，重启下才能生效
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/zyrflbesy0tkzp01pwhr.png)
Rubyist Hangout Thread
Tags: discuss, watercooler, ruby
Published: 2023-08-01 07:00:00

Hey folks, welcome to our weekly Rubyist hangout thread!

We're here to discuss all things Ruby, and since Ruby has been around for 28 years, it's a testament to its enduring greatness. However, don't feel limited by Ruby talk alone – this thread is also a place for Rubyists to share whatever they feel like within our community guidelines. So, whether it's Ruby-related or not, feel free to contribute and join in the conversation!

To make it easier for everyone to participate, we'd like to hear from you on the following:

**Highlight a Member:** 😄 Is there a fellow Rubyist whose contributions or achievements you'd like to highlight or appreciate? Let's celebrate each other's successes!

**Share an Article:** 📚 Have you come across an interesting article about Ruby, programming, or tech in general? Share it with the community and spark some insightful discussions.

**Something Happening in the Space:** 🚀 Is there an event, project, or any recent happening related to Ruby that you think others should know about? Let's keep each other informed.

Looking forward to hearing your thoughts and contributions. So, what's up this week?
Impactful Mentorships: How Did They Shape Your Journey?
Tags: discuss, career, learning
Published: 2023-08-01 07:00:00

_Discover diverse career growth stories and coding journeys in "Mentors & Mentorships" on The Daily Byte. Get inspired! 💻🌟_

> Discuss the most impactful mentorship you received in your career and how it influenced your growth as a developer.


Follow the DEVteam for more discussions and online camaraderie!

{% embed [https://dev.to/devteam](https://dev.to/devteam) %}
Coding Freedom: Exploring Opportunities in Remote Realms?
Tags: codenewbie, beginners, discuss, career
Published: 2023-08-01 07:00:00

_Welcome to "Discover Your Code," guided by our official DEV moderator, Sloan the Sloth 🦥. This series is designed to help aspiring coders and students explore the coding universe, ignite their passion, and find their ideal career paths._

Today's question is:

> Are you enticed by remote work opportunities, and where do you imagine that freedom might lead you?

Responses from newbies and experienced devs alike are encouraged in order to broaden our horizons and showcase different POVs.

Follow the [CodeNewbie Org](https://dev.to/codenewbieteam) and [#codenewbie](https://dev.to/t/codenewbie) for more discussions and online camaraderie!

*{% embed* https://dev.to/codenewbieteam *%}*
YouTube homepage - REDESIGN (Responsive)
Tags: codepen, css, webdev, ui
Published: 2023-08-01 06:53:42

<p>I'm excited to share an update on my YouTube homepage redesign project. I have implemented some changes to make the new design fully responsive across all devices.</p>

<p>UI design  inspired by </p>
[Behance](https://www.behance.net/gallery/112293293/Redesign-For-Youtube-UI?tracking_source=search_projects_recommended|youtube+redesign)
<p></p>
{% codepen https://codepen.io/Smit29/pen/mdQQgwZ %}
How To Configure CORS In Node.Js With Express?
Published: 2023-08-01 06:52:21

Internet browsers typically deny access to unknown websites from your application programming interfaces and services. Doing this allows your server to share its resources only with clients that are on the same domain as yours and nobody else. However, there are times when you would like to relax this guard or would want to exercise more control over which websites should be allowed access to your server’s resources. Implementing CORS in Node.js on your server is the answer to such cases.

In this blog, we will cover:

What is CORS in Node.js with Express?
What is Express.js?
What is Nodemon?
Hands-on

## What is CORS in Node.js With Express?
CORS is an acronym that stands for “Cross-Origin Resource Sharing.” Cross-Origin Resource Sharing (CORS) is a browser-implemented HTTP-header-based mechanism that allows a server or an API (Application Programming Interface) to indicate any origins (different in terms of protocol, hostname, or port) other than its own, from which the unknown origin can access and load resources.

## What is Express?
Express is a lightweight and adaptable Node.js web application framework that offers a comprehensive set of features for web and mobile applications. Creating a robust API is quick and easy with a plethora of HTTP utility methods and middleware at your disposal. Express adds a thin layer of fundamental web application features without interfering with the Node.js features you already know and love. Express is the foundation of many popular frameworks.

To know more about Express, refer to our blog here.

## What is Nodemon?
Nodemon is a popular tool for the development of node.js-based applications. It simply restarts the node application whenever it notices changes in the file in your project’s working directory.

## Required Installations

CORS: It is a package that helps us enable cross-origin requests with various options.
Express: It is basically a back-end web application framework for Node.js designed for building various web applications and APIs.
Nodemon: It is a tool that automatically restarts the server whenever it detects any changes in the codebase.

### **Hands-on**

For complete hands-on tutorial we can visit the original article at [How To Configure CORS In Node.Js With Express?
](https://www.workfall.com/learning/blog/how-to-configure-cors-in-node-js-with-express/)
Getting Started with the Vue TreeView Component
Tags: vue, webdev
Published: 2023-08-01 06:34:02

Learn how easily you can add the Syncfusion Vue TreeView component to a Vue application. The Vue TreeView, also known as the Vue Tree Menu, is a graphical user interface component that represents hierarchical data in a tree structure. It provides great performance with its advanced features like load-on-demand, checkbox support, multiple selection, tree navigation, drag and drop, tree node editing, and template support. 

Users can bind data to the TreeView component from any valid data source, such as XML, JSON, and JSONP. The tree data can be local or remote and fetched using different kinds of adaptors like OData, OData V4, URL, JSON, and Web API. The TreeView component has a load-on-demand option to load huge amounts of data dynamically, which improves the control’s performance. 

This video demonstrates how to bind data to the TreeView component from local and remote data sources. It also shows how to enable check box and drag and drop options in the TreeView component and how to edit and select multiple nodes at a time. 

**Product overview**: https://www.syncfusion.com/vue-components/vue-treeview

**Explore our tutorial videos**: https://www.syncfusion.com/tutorial-videos

**Example project**: https://github.com/SyncfusionExamples/getting-started-with-the-vue-treeview-component

{% youtube 7FTfAj_akD8 %}
One year of using Ubuntu as daily Operating System from Microsoft Windows
Published: 2023-08-01 06:23:19

Background Information
Firstly, personal information about myself, I am a software developer and uses computer mainly for writing codes and internet surfacing. Sometimes, I cut video and edit photos. Secondly, computer hardware information,  CPU is Ryzen 5 2400G and GPU is Radeon RX 470. I built the computer from parts and forgot about the wireless internet, so I use a usb plugged WIFI internet card instead. 

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/drvzwk1wblg5ozqso7pf.png)
General Taste
I don’t want to use Microsoft Windows 11 anymore, unless I have to do it.
Pros of Ubuntu
It is clean. The desktop is clean. The background app is clean. The menu is clean. In Windows 11 System, there is a weather widgets. For me, it is the most useless and annoying feature on the taskbar. When the mouse is over the weather section, a window jump out and cover a third of my screen, containing advertisement and outdated news from old media. There are also advertisement start menu of classic Windows. In Ubuntu there are zero 
advertisement and no such hover over window like weather widgets. In Windows 11, all the apps try to get a place at the desktop if not it will be tricky to find them. Then the desktop becomes crowded. Also many apps want to start when the operating system boost up. I know that I can set them not to do it, but sometime they start in the background. Then I find out my computer becomes mysteriously slow down. It need to be cleaned out and reset manually.
Here it is my desktop.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/wgy4gq8o72oab308t2sz.png)
It does all the tasks I demanded. It is capable with all the code editing program and has basic apps such as browsers, LibreOffice, printer drivers, database management and social medias… We use more and more online editing also. For example, google drive is able to edit all documents. Canva is great for videos and photos and more. There are also free and more powerful with AI assistance.
Due to its free and open-source Linux-based operating system, the system’s tools are more user friendly than Microsoft. Here is an example of screenshot.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/v1u0y6cmj9h49blevl0z.png)
Cons of Ubuntu
It takes time to adapt it. It requires users search information online to install apps and drivers. It could be pros if you want to learn how Operating System and software works  behind the sceens.
It doesn’t have video games. Also, it could be pros if you want to be effective and get ride of addiction.
How to Organize Testing Efforts
Published: 2023-08-01 06:10:15

Testing is a critical phase of any software development process. It ensures that the product meets the required standards, functions as expected, and delivers a seamless experience to end-users. However, testing efforts can become overwhelming and ineffective without proper organization. Hence, to achieve successful and efficient testing, a structured approach is essential.

[Read More @ ](https://tenjinonline.com/how-to-organize-testing-efforts/)