How js verifies undefined and null
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!