10.31
数据结构与算法:图的基本概念与各种图的知识点
学习了CSS引入方式,选择器,JS引入方式,对象的创建等
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<script>
//这是一个JSON格式的字符串
var personStr='{"name":"zhangsan","age":10,"dog":{"dname":"小花"},"friends":["shabi","dashabi","dadashabi"]}'
//通过JSON.parse()可以将一个JSON串转换为一个对象
var person=JSON.parse(personStr)
console.log(personStr)
console.log(person.name)
console.log(person.dog.dname)
console.log(person.friends[0])
//通过JSON.stringfy() 将一个对象转为JSON格式字符串
var personStr2=JSON.stringify(person)
</script>
</head>
<body>
</body>
</html>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<style>
.btn1{
width: 150px;
height: 40px;
font-size: 24px;
font-family: '隶书';
background-color:yellow;
color: brown;
border: 3px solid green;
border-radius: 5px;
}
</style>
<!--JS引入方式-->
<script>function surprise(){
//弹窗提示
alert("hello 我是你爹")
}
</script>
</head>
<body>
<button class="btn1" onclick="surprise()">点我有惊喜</button>
</body>
</html>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<script>
for(var i=1;i<=9;i++){
for(var j=1;j<=i;j++){
document.write(j+"*"+i+"="+(j*i)+" ")
}
document.write("<hr>")
}
//定义数组,并用for循环打印
var arr=["北京","傻瓜还","官洲"]
document.write("<ul>")
for(var index=0;index<arr.length;index++){
document.write("<li>"+arr[index]+"</li>")
}
document.write("</ul>")
//foreach打印
document.write("<ul>")
for(var index in arr){
document.write("<li>"+arr[index]+"</li>")
}
document.write("</ul>")
</script>
</head>
<body>
</body>
</html>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<script>
var a="dffdf"
console.log(a);
var monthStr=prompt("请输入月份")
//prompt返回的结果就是用户在窗口上输入的值,以string类型返回
console.log(typeof monthStr)
//字符串转换为整数
var month=Number.parseInt(monthStr)
console.log(typeof month)
</script>
</head>
<body>
</body>
</html>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<script>
var person =new Object()
//对象的属性
person.name="zhangsan"
person.age=10
//对象的方法
person.eat=function(food){
console.log(this.age+"的"+this.name+"正在吃"+food)
}
//访问属性:
console.log(person.name)
console.log(person.age)
//调用对象的函数
person.eat("火锅")
</script>
</head>
<body>
</body>
</html>