Blogger Information
Blog 25
fans 0
comment 0
visits 15893
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
0710作业
杨发国的博客
Original
502 people have browsed it

作业1创建一个构造函数

实例

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>js构造函数作业</title>
</head>
<body>
<script>


var CreateObj = function()
{
    this.dommin = 'php.cn';
    this.get = function (value) {
        var site = 'php中文网';
        return site + value;
    }
}
 var obj1 = new CreateObj();
    console.log(obj1.dommin);
    console.log(obj1.get(obj1.dommin));
    var obj2 = new CreateObj();
    console.log(obj2.dommin);
    console.log(obj2.get(obj2.dommin));

</script>
</body>
</html>
 
作业2:

实例

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>js构造函数作业</title>
</head>
<body>
<script>

var CreateObj = function()
{
    this.dommin = 'php.cn';
    this.get = function (value) {
        var site = 'php中文网';
        return site + value;
    }
}

CreateObj.prototype.email='yangfaguo@qq.com';
CreateObj.prototype.hellow=function () {
    return 'js不好玩';
};
   var obj= new CreateObj();
   console.log(obj.email);
  console.log(obj.hellow);
</script>
</body>
</html>

运行实例 »

点击 "运行实例" 按钮查看在线实例

11.png

 

点击 "运行实例" 按钮查看在线实例

22.png

Correction status:qualified

Teacher's comments:多个作业,请合并提交, 一个个看, 不便核对
Statement of this Website
The copyright of this blog article belongs to the blogger. Please specify the address when reprinting! If there is any infringement or violation of the law, please contact admin@php.cn Report processing!
All comments Speak rationally on civilized internet, please comply with News Comment Service Agreement
0 comments
Author's latest blog post