<!DOCTYPE html>
<html>
<body>
<h1>JavaScript 数组方法</h1>
<h2>toString()</h2>
<p>toString() 方法以逗号分隔的字符串返回数组:</p>
<p id="demo"></p>
<script>
var fruits = ["Banana", "Orange", 3, "Mango",null];
var rst = (document.getElementById("demo").innerHTML = fruits.toString());
(fruits[2] && (document.getElementById("demo").innerHTML = fruits.toString()));
console.log("TTTTT");
alert(rst);
(fruits[2] && console.log("AAA"));
</script>
</body>
</html>
----------------------------------------------------------------------------------------------------
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>菜鸟教程(runoob.com)</title>
</head>
<body>
<p>点击按钮检测年龄。</p>
年龄:<input id="age" value="18" />
<p>是否达到投票年龄?</p>
<button onclick="myFunction()">点击按钮</button>
<p id="demo"></p>
<p id="demo2"></p>
<script>
function functions(flag) {
if (flag) {
function getValue() { return 'a'; }
} else {
function getValue() { return 'b'; }
}
return getValue();
}
function myFunction()
{
var age,voteable;
age=document.getElementById("age").value;
voteable=(age<18)?"年龄太小":"年龄已达到";
(window.Jsonp = window.Jsonp || []).push([[0],[,,,,,,function(e,t,n){"use strict";}]]);
document.getElementById("demo").innerHTML=voteable;
document.getElementById("demo2").innerHTML=typeof(Jsonp);
var arr = arr || [];
arr[0] = "George";
arr.push(NaN);
arr[2] = "John";
arr.push("Thomas");
document.write(arr + "<br />");
document.write(arr.push("James") + "<br />");
document.write(arr + "<br />");
document.write(typeof(arr) + "<br />");
var aaa = functions(arr[1]);
document.write(aaa);
}
</script>
</body>
</html>