Background: Today review a piece of code to lead to my question, the code is as follows:
if (a === 'null') {
//
}
Copy the code
Q: How do null and strings interconvert?
- Null is converted to a string
let a = null + ' ';
Copy the code
- The ‘null’ string is converted to NULL
let a = JSON.parse('null'); // null
Copy the code