javascipt-Basics---Details that need attention:
1. Special values : NaN, Infinity, isNaN(), isFinite()
NaN:
var a=parseInt('a123 ');
window.alert(a); //Output NaN
Infinity:
window.alert(6/0 );//Output Infinity (it’s best not to write it like this)
isNaN(): Determine whether it is a number. If it is not a number, it returns true. If it is a number, it returns false.
var a="dd";window.alert(isNaN(a)); //Return true
isFinite(): Used to determine whether it is infinite. Returns false if number is NaN (not a number), or a positive or negative infinity number.
Copy code
The code is as follows:
In logical operations, 0, "", false, null, undefined, and NaN all represent false
(or || ) || will return the first value that is not false (objects are also acceptable), or the last value (if all are false)
This knowledge point is used a lot in JavaScript frameworks.
a、
Copy code
The code is as follows:
Copy code
The code is as follows:
Copy code
The code is as follows:
window.alert(aa); //returns d (object)
Copy code
The code is as follows:
case 'a':
window.alert("a ");
case 'b':
window.alert("b"); //There is no break statement and no match is successful. At this time, the results are output
}
Copy code
The code is as follows:
case 'a':
window.alert("a ");
case 1:
window.alert("b"); //There is no break statement. When the match is successful, no break statement will be found. At this time, b
}
5. Function call
func.js
Copy code
The code is as follows:
function test(num1,num2){
var res=0;
res =num1 num2;
return res;}
//Function without return value
function noVal(num1,num2){
var res=0;
res=num1 num2;
}
Function call:
Copy code
The code is as follows:
js supports functions with variable number of parameters
Statement:The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn