万物皆对象,数组是对象,数组可以存储元素,函数,数组等对象
创建数组的三个方式:
- 常规方式:var myCars = new Array();
- 简介方式:var myCars = new Arrray("Benz","BMW",“Audi”);
- 字面:var Array = ["Benz","BMW","Audi"];
<script> var i; var myCars = new Array(); var myCars1 = new Array("a","b","c"); var myCars2 = new Array("z","y","w"); myCars[0] = "Benz"; myCars[1] = "BMW"; myCars[2] = "Audi"; for(i = 0; i < myCars.length; i ++){ document.write(myCars[i]+"<br/>"+myCars1[i]+"<br/>"+myCars2[i]+"<br/>"); } </script>
Boolean对象:
如果布尔对象的初始值为以下,则它是false:
- 0
- -0
- null
- ""
- false
- undefined
- NaN
Math对象:
- 用于执行数学任务,比如求平方根sqrt(),比如π,pi
原文地址:https://www.cnblogs.com/ltfxy/p/11651262.html
时间: 2024-10-15 06:03:10