<! DOCTYPE HTML PUBLIC "-//w3c//dtd HTML 4.01 transitional//en" "HTTP://WWW.W3.ORG/TR/HTML4/LOOSE.DTD" >
<meta http-equiv= "Content-type" content= "Text/html;charset=utf-8" >
<title>Document</title>
<style>
/*CSS Reset Start */
body,h1,h2,h3,h4,h5,h6,p,dl,dd,ul,ol,pre,form,input,textarea,th,td,select{margin:0;padding:0;font-size:14px; font-family: "Microsoft Yahei";}
Input{width:300px;height:20px;vertical-align:middle;}
Li{list-style:none;vertical-align:top;}
A{text-decoration:none;}
Img{border:none;vertical-align:top;}
Table{border-collapse:collapse;}
Textarea{resize:none;overflow:auto;}
body{margin-top:10px;}
/*CSS Reset End */
form{width:300px;}
fieldset{margin:20px;border:2px dashed palevioletred;}
</style>
<script>
Window.onload = function () {
var arr = [' 100px ', ' abc '-6, [], -98765, $,-2, 0, ' + ',, function () {alert (1);}, null, document, [], True, ' 200px '-30, ' 23.45 Yuan ', 5, Number (' abc '), function () {alert (3);}, ' XYZ '-90];
var oallnum = document.getElementById (' Allnum ');
var onum = document.getElementById (' Num ');
var omaxnum = document.getElementById (' Maxnum ');
var onanlocation = document.getElementById (' nanlocation ');
var arr1 = [];
var arr2 = [];
var arr3 = [];
/
/1. All the numbers in the array: ↓↓
for (Var i=0;i<arr.length;i++) {
if (typeof arr[i] = = ' number ' && arr[i] = = = Arr[i]) {
Arr1.push (Arr[i]);
}
}
Oallnum.value = arr1;
//
2. The array can be converted into numbers: ↓↓
for (Var i=0;i<arr.length;i++) {
if (IsNaN (parseint (arr[i)) = = False) {
Arr2.push (Arr[i]);
}
}
Onum.value = arr2;
//
3. Can be converted to a number and then take the maximum value: ↓↓
var tmp =arr2;
var max = tmp[0];
for (Var i=1;i<tmp.length;i++) {
if (Max<tmp[i])
{
Max=tmp[i];
}
}
Omaxnum.value=max;
//4.NAN location: ↓↓
for (Var i=0;i<arr.length;i++) {
if (typeof arr[i] = = ' number ' && IsNaN (number (arr[i))) {
Arr3.push (i);
}
}
Onanlocation.value = ARR3;
}
</script>
<body>
<form action= "" >
<fieldset>
<legend> Output Results </legend>
All numbers in arr array: <input type= "text" id= "Allnum"/><br/><br/>
The ARR array can be converted into numbers: <input type= "text" id= "Num"/><br/><br/>
After turning into a number, take the maximum value: <input type= "text" id= "Maxnum"/><br/><br/>
Nan Location: <input type= "text" id= "Nanlocation"/>
</fieldset>
</form>
</body>
Value of array judgment