Get the App
SLTechnology News&Howtos  ›  Development  › 

How js verifies undefined and null

Shulou Source: shulou.com Published: 2022-06-01 05:55:26 09月12日 Update

This article mainly introduces js how to verify undefined and null, the article is very detailed, has a certain reference value, interested friends must read it!

Verify undefined and null

If there is a code like this:

If (a = = null | | a = undefined) {doSomething ()}

That is, if you need to verify that a value is equal to null or undefined, and you need to perform an operation, you can use the null merge operator to simplify the above code:

A?? DoSomething ()

In this way, the code after the control merge operator is executed only if an is undefined or null. The null merge operator is a logical operator that returns its right Operand when the left Operand is null or undefined, otherwise it returns the left Operand.

The above is all the content of the article "how js verifies undefined and null". Thank you for reading! Hope to share the content to help you, more related knowledge, welcome to follow the industry information channel!

Tags: Validation code operands content operators articles operators operations that is value interest only right side guys buddies more knowledge industry information information channels Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Shulou Tech Info OPPO Reno vpn Shulou Technology Huawei