Prototype-array-last
提供:Dev Guides
プロトタイプ-last()メソッド
このメソッドは、配列の最後のアイテムを返すか、配列が空の場合はundefinedを返します。
構文
array.last();
戻り値
配列の最後の要素を返します。
例
<html>
<head>
<title>Prototype examples</title>
<script type = "text/javascript" src = "/javascript/prototype.js"></script>
<script>
function showResult() {
var arr = ['Apples', {good: 'yes', bad: 'no'}, 3, 34];
alert("Last Element : " + arr.last() );
}
</script>
</head>
<body>
<p>Click the button to see the result.</p>
<br/>
<br/>
<input type = "button" value = "Result" onclick = "showResult();"/>
</body>
</html>