Este artigo descreve o método JS de troca de variáveis. Compartilhe para sua referência. O método de implementação específico é o seguinte:
A cópia do código é a seguinte:
<html xmlns = "http://www.w3.org/1999/xhtml">
<head>
<Title> </title>
<script type = "text/javascript">
função jh (arr) {
for (var i = 0; i <arr.length / 2; i ++) {
var tem = arr [i];
arr [i] = arr [arr.length -i - 1];
arr [arr.length -i - 1] = tem;
}
}
var nomes = new Array ();
nomes [1] = "tom";
nomes [2] = "lily";
nomes [3] = "jek";
jh (nomes);
alerta (nomes);
</script>
</head>
<Body>
</body>
</html>
Espero que este artigo seja útil para a programação JavaScript de todos.