Blogger Information
Blog 38
fans 1
comment 0
visits 24260
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
5月6日javascript 作业2
鲨鱼辣椒的博客
Original
504 people have browsed it

2. 写一个对象字面量, 描述一款喜欢的手机信息

代码如下:

实例
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>2. 写一个对象字面量, 描述一款你喜欢的手机信息</title>
</head>
<body>
<script>
    var obj = {
        //对象属性
        'x-name': 'JM',
        username: 'king',
        phone_name: 'iphone xs max',
        cup: 'iphone a12',
        battery: '3174 mAh',
        fbl: '2688x1242像素',

        // 对象方法
        getName: function(){
            return this['x-name'] + '用户:' + this.username + ',手机名称:' + this.phone_name + ',处理器:' + this.cup + ',电池容量' + this.battery;
        }
    };

    console.log(obj.getName());
    console.log(obj.fbl);

</script>
</body>
</html>
运行实例 »
点击 "运行实例" 按钮查看在线实例


Correction status:Uncorrected

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