1 introduction

By accident, Number(null) outputs 0. So, what other situation would it print 0?

2 Experiment and results

The test code

<script>
    console.log("* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *");
    console.log("* * * * * * * * * * * * * * * * * * * * * * * southern person - the nuggets * * * * * * * * * * * * * * * * * * * * * * * * *");
    console.log("* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *");
    console.log("* * * * * * * * * * * * * * * * * * test js - Number () what the * * * * * * * * * * * * * * * * *");
    console.log("* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *");
    console.log("Number(0)=".Number(0));/ / 0
    console.log("Number(\"\")=".Number(""));/ / 0
    console.log("Number(\" \")=".Number(""));/ / 0
    console.log("Number(null)=".Number(null));/ / 0
    console.log("Number(undefined)=".Number(undefined));/ / output NaN
    console.log("The Number (12.0252) =".Number(12.0252));/ / output 12.0252
    console.log("Number (\" 12.0252 a \ ") =".Number("12.0252啊"));/ / output NaN
</script>
Copy the code

The results show

3 conclusion

Not only does Number(null) output 0, but also Number(” “), and the examples in the experiment will output 0.

4 the last

Thank you for reading the end, if you have a different view, you are welcome to leave a comment below this article. I am a southerner who loves computers and loves the motherland. If the content of this article is only for learning reference, if there is any infringement, I am very sorry, please contact the author immediately delete.