Last active
June 26, 2022 07:33
-
-
Save topmask/7d41858acb347b45093543a99e356de0 to your computer and use it in GitHub Desktop.
以数字形式输入值
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const numInput = document.getElementById('num-input'); | |
let num; | |
// Bad: parseFloat() converts the string to a number | |
num = parseFloat(numInput.value); | |
// Good: returns a numeric value | |
num = numInput.valueAsNumber; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment