2018/09/12JavaWeb系统学习 JavaScript知识点回顾

String对象:

  • 属性:length返回字符串的长度
  • 方法:
  1. splite(“str”),返回值为一个数组
  2. concat(str2)
  3. replace(st,str2):用str替代字符st的字符
  4. charAt(i):返回第i个字符是什么
  5. indexOf(st):返回第一次出现st的位置
  6. substr(i,j)从i开始,向后截取j个字符
  7. substring(i,j)截取从i到j(不含)的字符[i,j)

Array对象:

  • 属性:length
  • 方法:
  1. push():如果push的参数是一个数组,则表示的是将这个数组里面的对象当做一个字符串穿进去了,无论push的数组有几个元素,都看做加入了一个元素
  2. pop()
  3. concat()
  4. reverse()
  5. join():分割数组,默认用","隔开
		var arr1 = [11,"san",true]
		var arr2 = Array("hu","chen","xu")
		arr1.push(arr2)
		//以下结果为2
		document.write(arr1.length)
		document.write("
") //以下结果为 hu,chen,xu document.write(arr1[3]) document.write("
") //以下结果为11-san-true-hu,chen,xu document.write(arr1.join("-")) document.write("
")

Date对象:

		//以下结果为:2018年9月12日下午4:01:32
		document.write(new Date().toLocaleDateString() + new Date().toLocaleTimeString())
		document.write("
") //获得当前日期 document.write(new Date().getDate()) document.write("
") //获得当前星期 document.write("星期"+new Date().getDay()) document.write("
") //获得当前年份 document.write(new Date().getFullYear()) document.write("
") //获得当前是几点 document.write(new Date().getHours()) document.write("
") //获得获得当前分钟数 document.write(new Date().getMinutes()) document.write("
") //获得的值为当前月份-1, document.write("月份"+new Date().getMonth()) document.write("
") //获得当前秒数 document.write(new Date().getSeconds())

Math对象(静态对象,调用时无需new,直接用Math.):

函数:

  • floor(x):向上取整
  • ceil(x):向下取整
  • round(x):四舍五入
  • random(x):获得一个[0,1)范围内的伪随机数

属性:

PI:圆周率,用于圆,圆锥等物体体积面积体积的计算

 

BOM对象:

  • window:顶层窗口对象(一下四个对象皆为window的底层对象)
  • history:
  1. back()
  2. forward()
  3. go(url|x):x为正,表示后x个页面,x为负,表示前x个界面
	
		
		
  • location:location.href(获得当前路径),设置location.href可以到达跳转路径

点击Click按钮,跳转到test1.html

		
		
  • screen: 了解height(),width()
  • navigator:获取客户机(浏览器)的信息

 

window顶层对象 :

  • window.confirm():返回值true/false
  • 2018/09/12JavaWeb系统学习 JavaScript知识点回顾_第1张图片
  • setInterval("js代码",毫秒数),clearInterval(setInterval的name)
  • setTimeout(“js代码”,毫秒数),clearTimeOut(setTimeout的name)
  • window.opener属性获得打开此窗口的窗口(之后获取该窗口内的内容获操作该窗口只需在操作前加上window.opener)[访问的是本地的路径的话,在安全性较高的浏览器中无法实现]

跨页面操作

	
		
张三 18
王五 15
李四 20

 

你可能感兴趣的:(I‘ve,learned,something,today,JavaWeb,html,javascript)