<script> function square(x,y) { //数组x,y分别按顺序存储各点的横、纵坐标值 var sum0=0; for (var i = 0; i < x.length - 1; i++) { sum0 += (x[i] * y[i + 1] - x[i + 1] * y[i]); } var square = (Math.abs(sum0 + (x[i] * y[0]) - (x[0] * y[i]))) / 2; return square; } </script>