Blogger Information
Blog 35
fans 0
comment 0
visits 22336
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
JS基础知识(对象的创建)--2018年9月18日17:28:06
Hi的博客
Original
709 people have browsed it

在js中一切皆对象.对象的使用时非常频繁的.我来演示下,用字面量和构造函数的方法来创建对象

js的代码是写在html中的使用一对script标签来表示

以下是我的代码

实例

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>使用字面量和构造函数创建对象</title>
</head>
<body>
<script>
//1.构造函数创建对象
let obj = new Object();
obj.name = '小明';
obj.age = 15;
obj.salary= 6000;
//2.使用字面量创建函数
let  boj1 = {
    name: '小明',
    age: 29,
    alary: 6000
}
</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