<!DOCTYPE html>
<html>
<head>
<title>01_define.html</title>
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="this is my page">
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<!--<link rel="stylesheet" type="text/css" href="./styles.css">-->
<script type="text/javascript">
console.log('js中对象的创建');
//js中不存在类,所以可以直接通过Object来直接创建对象
//但是使用如下方式,带来的最大问题是,由于没有类的约束,无法实现对象的重复利用,并且没有约定在操作时会带来问题
var person = new Object();
person.name = 'evy';
person.age = 12;
person.say = function(){
console.log(this.name+','+this.age);
}
person.say();
</script>
</head>
<body>
This is my HTML page. <br>
</body>
</html>
JS 对象的创建(一)
最新推荐文章于 2023-04-30 16:29:15 发布