【无标题JS对象–1,内置对象

<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title>测试 js对象</title>
		<script>
			//1,JS的内置对象
			function test1(){
				//String对象的功能
				let a = 'javascript';
				console.log( a.length ); //获取字符串的长度
				console.log( a.toUpperCase() ); //全转大写
				let b = a.substring(1,5); //截取字符串[1,5)
				console.log( b ); 
				console.log( a.concat('hello ~') );  //拼串
				//Math对象
				console.log( Math.PI );//π的值
				console.log( Math.random() ); //随机数0~1
				console.log( Math.random() * 10 );
				console.log( Math.round(1.9) );//对小数的处理,round四舍五入
				console.log( Math.round(1.1) );//对小数的处理,round四舍五入
				//Array对象
				let c = [3,2,4,5,2];
				console.log( c );
				console.log( c.toString() );//打印数组里的数据
				console.log( c.sort() ); //对数组排序,默认从小到大
				//window对象--可以省略
				window.alert(100);//弹出框
				window.prompt(); //输入框
				window.confirm() ;//确认框
				//DOM 
				Document d = window.document;
				//JSON
			}
		</script>
	</head>
	<body>
		<!--2,调用函数  -->
		<button onclick="test1()">单击按钮</button>
	</body>
</html>

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值