<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
</head>
<body>
<div class="demo">
<ul>
<li v-for="(item, index) of user" :key="index">
{
{ data.user.name}}
</li>
</ul>
<button @click="add">添加</button>
</div>
<script>
// var a = function () {
// return 222
// }
// console.log(a()) //222
// // 返回的是a里边的函数函数值
// let a = () => 222
// console.log(a())
// var b=function(c,d){
// return c+d
// }
// console.log(b(1,4)) //5
// // // 返回的是b里边的函数函数值
// let b=(c,d)=>c+d
// console.log(b(1,4))
// 一个参数可以不写括号
// d是形参没有实际的意义
// var c=function(d){
// return d
// }
// console.log(c(1111))
// let c = d => d
// console.log(c(11111))
// // 定义结构
// function kk(n){
// var digui = function(n){
// // 进行判断
// if(n===15){ //n是不是等于15
// return 'you' //等于返回 " you"
// }else if (n !==15){ //n不等于15
// return 'meiy ' //不等于返回meiy
// }else{ // 如果不是
// return digui(n-1) //每次减一
// }
// return digui //返回每次减一的值给if在进行判断
// }
// return digui (n)
// // 每次循环减一,直到减到15 打印然后在返回到原来的值
// // 这个过程就是递归
// }
// console.log(kk(15))
// // 闭包、
// function kk(){ //父函数
// var a =10 //定义变量
// function ff (){ //子函数
// console.log(a) //子函数打印变量
// }
// return ff() //返回子函数的所有值
// }
// kk( ) //外部打印父函数 获取子元素的值
// // 外边函数调用里边的值这个就是闭包
// var a = [1,0,9,8,7];
// var b = a;
// var c = a[0];
// console.log(b); //[1,0,9,8,7]
// console.log(c); //1
// //改变数值
// b[1] = 3;
// c = 5;
// console.log(b) //
// console.log(a)
// console.log(b[1]); //3
// console.log(a[0]); //1
// // 继承
// function
// // 定义原有变量
// Person(name,age,gender){
// this.name = name || '' ;
// this.age = age || '';
// this.gender = gender || '';
// }
// // 通过原型输出name
// Person.prototype.sayHi = function(){
// console.log(" I am" + this.name)
// }
// // 定义student的变量
// function Student(name,age,gender,score){
// // person通过call改变了this指向,同时传递name,age,gender
// Person.call(this,name,age,gender)
// }
// // 通过原型继承 继承(person)方法
// Student.prototype = new Person()
// // 修改了constructor的指向
// Student.prototype.constructor = Student;
// // 动态添加成员方法(添加成员)
// Student.prototype.printScore = function(){
// console.log('my' +this.score)
// }
// // 创建实例对象
// var s1 = new Student('s', 30, '男', 90)
// s1.sayHi()
// s1.printScore()
// 定时器执行
// var
// helloword = (function(){
// console.log('hello one');
// setTimeout(function(){
// console.log('hello two')
// },100)
// setTimeout(function(){
// console.log('hell three')
// },2000)
// console.log('heloods')
// }())
// // 冒泡排序
// function
// sortBubble(arr){
// for(var i= 0;i<arr.length;i++){
// for(var j=0;j<arr.length-i;j++){
// if(arr[j]>arr[j+1]){
// var temp= arr[j]
// arr[j] = arr[j+1]
// arr[j+1] = temp
// }
// }
// }
// return arr
// }
// 数组去重
// // set方法
// var arr = [1,2,2,3,3,44,4]
// function uniquw(arr){
// // from 将类数组对象转换为真正数组:
// return Array.from(new Set(arr))
// }
// console.log(uniquw(arr))
// // 循环判断
// var arr = [1,2,2,3,3,44,4]
// function uniquw(arr){
// for (var i= 0; i<arr.length;i++){ //首次循环
// for(var j=i+1;j<arr.length;j++){ //再次循环
// if(arr[i] == arr[j]){ //查看第一次和第二次的判断是否一样
// arr.splice(j,1) //删除
// j-- //每次减一
// }
// }
// }
// return arr
// }
// console.log(uniquw(arr))
// // 闭包
// // 定义变量
// var count = 0
// // 创建函数
// var fn1 = function(){
// // 返回函数每次加一
// return function(){
// count ++
// console.log(count)
// }
// }
// // 赋值
// var fn2= fn1()
// fn2()
// fn2()
// fn2()
// 赋值
// var a={
// id:19
// }
// b=a
// b.id= 1
// b.name= 'test'
// console.log(a)
// // 请求
// xhr.setRequestHeader("Content-Type",'application/x-www-from-urlencoded')
// xhr.send('name=zs&age=18')
// xhr.onreadystatechange=function(){
// if(xhr.status==200&&xhr.readyState==4){
// var json=xhr.reaponseText&&JSON.parse(xhr.responseText)
// var xml=xhr.responseXML
// console.log(json,xml)
// }
// }
// resolve 配置路径
// resolve:{
// alias:{
// $css:resolve(__dirname,'src/css')
// }
// }
// resolve:{
// alias:{
// $css:resolve(__dirname,'src/css')
// }
// }
// 省略拓展名的后缀
// resolve:{
// extensions:['.js','.json','.jsx','.css']
// }
// resolve:{
// extensions:['.js','jsx','.json',' .css']
// }
// $set
// 使用vue2打开
// 输出
// export default {
// name : 'nihai',
// data (){
// return {
// user:{
// age : 12,
// names : 'zhoy'
// }
// };
// },
// created(){
// console.log('created 声明周期' ,this.user)
// },
// updated() {
// console.log(this.user)
// },
// metods:{
// add(){
// this.$set(this.user,'scor' , 300)
// }
// }
// }
// export default{
// name: 'nihao',
// data(){
// return{
// user :{
// name:'niha',
// age:13
// }
// };
// },
// created(){
// console.log(this.user)
// },
// methods:{
// add(){
// this.$set(this.user,'dsjfosjf',90)
// }
// }
// }
let vm = new Vue({
el:'#app',
data:{
mes:"我是一个悲观的人,悲观的人做悲观的事"
}
})
Vue.filter('setStr',function(data){
// 过滤器中必须有一个返回值
return data.replace(/悲观/g,'开朗')
// 使用字符串操作方法 replace 替换字符串内某些元素为其他元素,g 代表全局匹配
})
// export default {
// name: "demo",
// data() {
// return {
// user: {
// name: "xiaochen",
// addr: "china",
// userAge: 18,
// },
// };
// },
// created() {
// console.log('created生命周期:',this.user);
// },
// updated() {
// console.log('updated生命周期:',this.user);
// },
// methods: {
// add() {
// this.$set(this.user, "score", 90);
// },
// },
// };
</script>
</body>
</html>
<!-- <!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
</head>
<body>
<script>
// 解构
// //定义
// const F4 = ['小沈呀','刘能','赵四','宋小宝']
// //解构
// let [xiao,liu,zhao,song] = F4
// console.log(xiao)//小沈呀
// console.log(zhao)//赵四
// // ----------------------------------------------
// // 对象解构
// const zha = {
// name :'咋说的老师',
// age:'no',
// bioayan :function(){
// console.log('我说的是你')
// }
// }
// // 解构
// let {name,age,bioayan} = zha
// console.log(name)//咋说的老师
// console.log(bioayan)//ƒ (){ console.log('我说的是你')
// ----------------------------------------------------------
// 变量拼接
// let name1 = '悦悦'
// let job = `${name1} ljaja`
// console.log(job) //悦悦 ljaja
// ----------------------------------------------------------
//ES6函数允许给函数参数赋初始值
// connect({
// a: 1,
// b: 2,
// });
// function connect({ a, b, c = 101 }) {
// console.log(a) //1
// console.log(b) //2
// console.log(c) //3
// }
// ----------------------------------------------------------
// 剩余参数
// function fun(a,b,...args){
// console.log(a) //1
// console.log(b) //2
// console.log(...args) //3 4 5 6 7
// }
// fun(1,2,3,4,5,6,7)
// -------------------------------------------------------
// function fun(a,b,...args){
// console.log(...args)
// }
// fun(1,2,3,4,5,6,7)
// let arr = [1, 2, 3, 4, 5, 6];
// function fun() {
// console.log(arguments);
// }
// fun(...arr); //扩展运算符
// // 多个扩展
// let arr1 = ['kl','kkk']
// let arr3 = [1, 2, 3, 4, 5, 6];
// let arrrr = [...arr1,...arr3]
// console.log(arrrr) //['kl', 'kkk', 1, 2, 3, 4, 5, 6]
// ----------------------------------------------------------
// //扩展运算符
// // 就是把每个变成独立的个体 , 逗号分开
// let arr = [1, 2, 3, 4, 5, 6];
// function fun() {
// console.log(arguments);
// }
// fun(arr); //没扩展
// fun(...arr); //扩展运算符
// // 多个扩展
// let arr1 = ['kl','kkk']
// let arr3 = [1, 2, 3, 4, 5, 6];
// let arrrr = [...arr1,...arr3]
// console.log(arrrr) //['kl', 'kkk', 1, 2, 3, 4, 5, 6]
// ----------------------------------------------------------
// Symbol 独一无二的
// Symbol.for 不是独一无二的 可以进行全等比较
// let s = Symbol()
// console.log(s)
// Symbol
// // let s2 = Symbol('速度快')
// // console.log(s2)//速度快
// // let s3 = Symbol('速度快')
// // console.log(s3)//速度快
// // console.log(s2===s3)//false
// / Symbol.for
// let s4 = Symbol.for('速度快')
// console.log(s4)//Symbol(速度快)
// let s5 = Symbol.for('速度快')
// console.log(s5)//Symbol(速度快)
// console.log(s4===s5)//true
// ----------------------------------------------------------
// 迭代器
// // iterator next() 使用方法
// let Uname = ["搜到", "的撒", "的风格", "范德萨", "公司发", "告诉对方"];
// // for(let a of Uname){
// // console.log(a) //搜到 的撒 的风格 范德萨 公司发 告诉对方
// // }
// let iterator = Uname[Symbol.iterator]()
// console.log(iterator.next())//{value: '搜到', done: false}
// console.log(iterator.next())//{value: '的撒', done: false}
//false表示数组成员没遍历结束,true表示结束。
// ----------------------------------------------------------
// 生成器、
// function *fun2(){
// yield"刷卡啥"
// yield"aaa"
// }
// let tor = fun2()
// console.log(tor.next())//{value: '刷卡啥', done: false}
// console.log(tor.next())//{value: 'aaa', done: false}
// console.log(tor.next())//{value: undefined, done: true}
// function* fun2(arg) {
// console.log(arg)
// let A = yield '一直没有耳朵';
// console.log(A)
// let B = yield '一直没有尾巴';
// console.log(B)
// let C = yield '真奇怪';
// console.log(C)
// }
// let tor = fun2('aaa')
// console.log(tor.next())
// console.log(tor.next('bbb'))
// console.log(tor.next('ccc'))
// console.log(tor.next('ddd'))
// ----------------------------------------------------------
// // 定义定时器
// function getFGoods() {
// setTimeout(() => {
// let data = '用户数据'
// iterator.next(data)
// }, 1000)
// }
// function getOrder() {
// setTimeout(() => {
// let data = '嗜睡睡'
// iterator.next(data)
// }, 222)
// }
// function getUser() {
// setTimeout(() => {
// let data = '嗜睡睡ss'
// iterator.next(data)
// }, 44)
// }
// // 生成实例
// function* fun3() {
// let user = yield getUser()
// console.log(user)
// let Order = yield getOrder()
// console.log(Order)
// let Goods = yield getFGoods()
// console.log(Goods)
// }
// let iterator = fun3()
// iterator.next()
// ----------------------------------------------------------
// // 增删、
// // let se = new Set() //声明一个set
// let se2 = new Set (['da','xiao'])
// console.log(se2)//{'da', 'xiao'}
// // 添加新元素
// se2.add('xskkkk')
// console.log(se2)//{'da', 'xiao', 'xskkkk'}
// // 删除
// se2.delete('da')
// console.log(se2)//{'xiao', 'xskkkk'}
// // 检测
// console.log(se2.has('da')) //false
// // 清空
// se2.clear()
// console.log(se2)//Set(0) {size: 0}
// -------------------------------------------------------------------------------------
// let m= new Map()
// m.set('name','zmy') //name zmy
// m.set('chenge',function(){ //chenge function
// console.log(111)
// })
// let key = {
// school:'aygh'
// }
// m.set(key,'kkkk') //object kkkk
// console.log(m)//Map(3) {'name' => 'zmy', 'chenge' => ƒ, {…} => 'kkkk'}
// console.log(m.size)//3
// -------------------------------------------------------------------
// //一个普通函数
// function getData(){
// return 'ayy'
// }
// console.log(getData())//ayy
// //加上async后
// async function getData(){
// return 'kkk'
// }
// console.log(getData())//Promise {<fulfilled>: 'kkk'}
// async function getData(){
// return 'ayy'
// }
// // 监听getData
// getData().then(data=>{
// console.log(data) //ayy
// })
// ----------------------------------
// =====================$
// async function getData(){
// throw new Error ('出错了')
// }
// getData()
// .then(
// v=>console.log(v),
// e=>console.log(e) //Error: 出错了
// )
// async function getData(){
// return new Promise((resolve,rejext) =>{
// setTimeout(()=>{
// var name = 'asss'
// resolve(name)
// },99)
// })
// }
// async function tset(){
// var p= await getData()
// console.log(p)
// }
// tset()//'asss'
// -----------------------------------------------------------
// 扩展运算符
// let { x, y, ...z } = { x: 1, y: 2, a: 3, b: 4 };
// x // 1
// y // 2
// z // { a: 3, b: 4 }
// ES10数组扩展方法flat:将多维数组转换为低维数组
// let arr14 = [1, 2, 3, 4, [5, 5, 6]]
// console.log(arr14.flat())
// // 私有属性
// class Person {
// //公有属性
// name;
// //私有属性
// #age;
// #weight;
// constructor(name, age, weight) {
// this.name = name
// this.#age = age
// this.#weight = weight
// }
// con() {
// console.log(this.name)
// console.log(this.#age)
// console.log(this.#weight)
// }
// }
// const girl = new Person('Lisa', 17, '45g')
// console.log(girl)
// girl.con()
// // 构造函数继承
// class Phone {
// //构造方法
// constructor(price, name) {
// this.price = price
// this.name = name
// }
// calll() {
// console.log('我可以改变世界')
// }
// }
// class smallcall extends Phone {
// //构造方法
// constructor(price, name, color, size) {
// super(price, name) //调用父类的constructor方法
// this.color = color
// this.size = size
// }
// photo() {
// console.log('111')
// }
// }
// const mi = new smallcall(133, '小米', 'red', 4.7)
// console.log(mi);
// =================================================================================$
// for 循环
// let i = 0
// for ( let i = 0;i<20; i++ ){
// console.log(i)
// }
// 数组
// let arrayLike = {
// '0': 'T',
// '1': 'h',
// '2': 'i',
// '3': 'n',
// '4': 'k',
// length: 5
// };
// const arr = Array.from(arrayLike)
// console.log(arr) //['T', 'h', 'i', 'n', 'k']
// // 遍历索引
// for (let index of arr.keys()) {
// console.log(index);
// }
// // 遍历索引和值
// for (let [index, elem] of arr.entries()) {
// console.log(index + ' +-+' + elem);
// }
// -----------------------------------------------------------
// function Mayday(a, b, c, d, e) {
// // console.log(a + ', ' + b + ', ' + c + ', ' + d + ', ' + e + ', ')
// console.log(a, b, c, d, e) //Monster Ashin Stone Matthew Tsai Lau Ming
// }
// const args = ['Monster', 'Ashin', 'Stone', 'Matthew Tsai', 'Lau Ming'];
// // es5写法
// Mayday.apply(null, args);
// // es6写法
// Mayday(...args);
// -----------------------------------------------------------
// function add(a, b, c) {
// return a + b + c;
// }
// let arr = [1, 2, 3];
// let result = add(...arr); // 此处使用了展开运算符
// console.log(result); //6
// -----------------------------------------------------------
// es6 对象字面量
// var listeners = [] //创建数组
// function listen(){} //创建对象
// var events = {listeners,listen} //赋值解构给events
// // 对象字面量 计算属性
// var expertise = 'jok' //先定义一个变量
// var person = { //创建一个对象 定义数据
// name :'ninhao',
// age:28,
// // [expertise]: 是简写属性 不可和计算属性 同时使用
// [expertise]:{ //[expertise]这样写 就是相当于在的expertise基础上加东西
// yue:22,
// inko:['lha','lsjd']
// }
// }
// console.log(person)
// // 计算属性 一个新的对象 引入另一个对象的某个数据
// var grou = {
// id:'bananas',
// name:'Baa',
// age:19
// }
// var klkl ={
// [grou.id] :grou, //全部数据
// [grou.id] :grou.id, //单个数据
// kl:'asjlaj' //后添加的数据
// }
// console.log(klkl)
// -----------------------------------------------------------
// 没搞懂
// function getEnvelope(type, description) {
// return {
// data: {},
// [type]: description
// }
// }
// console.log(getEnvelope)
// // es6方法定义
// var emitter ={
// events:{
// type:'ajajep'
// },
// on(type, fn) {
// if (this.events[type] === undefined) {
// this.events[type] = []
// }
// this.events[type].push(fn)
// },
// emit(type, event) {
// if (this.events[type] === undefined) {
// return
// }
// this.events[type].forEach(function (fn) {
// fn(event)
// })
// }
// }
// console.log(emitter)
// var timer = {
// seconds: 20,
// start() {
// setInterval(() => {
// this.seconds++
// }, 100)
// }
// }
// timer.start()
// setTimeout(function () {
// console.log(timer.seconds)
// }, 300)
// // <- 3
// -----------------------------------------------------------
// var character = {
// name:'Bruce',
// pseudonym:'Bruce',
// metadata:{
// age:32,
// gender:'male'
// },
// batarang: ['gas pellet', 'bat-mobile control', 'bat-cuffs']
// }
// // 解构多个
// var { pseudonym, name } = character
// // 解构添加数据
// var { pseudonym } = character, two = 2
// console.log(two)
// // 结构对象
// var { metadata: { gender } } = character
// // 添加解构对象
// var { boots = { size: 10 } } = character
// console.log(boots)
// // <- { size: 10 }
// -----------------------------------------------------------
// 数组解构
// var names = ['James', 'L.']
// var [ firstName = 'John', , lastName = 'Doe' ] = names
// console.log(lastName)
// var car = {
// owner: {
// id: 'e2c3503a4181968c',
// name: 'Donald Draper'
// },
// brand: 'Peugeot',
// make: 2015,
// model: '208',
// preferences: {
// airbags: true,
// airconditioning: false,
// color: 'red'
// }
// }
// // 单个解构
// // var { brand } = car
// // console.log(brand) //Peugeot
// // 多个解构 并 修改
// var getCarProductModel = ({ brand, make, model ,preferences:{ airbags ,color}}) => ({
// sku: brand + ':' + make + ':' + model + airbags +color,
// brand,
// make,
// model
// })
// // getCarProductModel(car)
// console.log(getCarProductModel(car))
// 解构使用示例
// 当一个函数的返回值为对象或者数组时,使用解构,我们可以非常简洁的获取返回对象中某个属性的值(返回数组中某一项的值)。比如说,函数getCoordinates()返回了一系列的值,但是我们只想用其中的x,y,我们可以这样写,解构帮助我们避免了很多中间变量的使用,也使得我们代码的可读性更高。
// function getCoordinates() {
// return { x: 10, y: 22, z: -1, type: '3d' }
// }
// var { x, y } = getCoordinates()
// 通过使用默认值,可以减少重复,比如你想写一个random函数,这个函数将返回一个位于min和max之间的值。我们可以分辨设置min默认值为1,max默认值为10,在需要的时候还可以单独改变其中的某一个值:
// function random({ min = 1, max = 10 } = {}) {
// return Math.floor(Math.random() * (max - min)) + min
// }
// console.log(random())
// // <- 7
// console.log(random({ max: 24 }))
// // <- 18
// 解构还可以配合正则表达式使用。看下面这个例子:
// function splitDate(date) {
// var rdate = /(\d+).(\d+).(\d+)/
// return rdate.exec(date)
// }
// var [ , year, month, day] = splitDate('2015-11-06')
// 不过当.exec不比配时会返回null,因此我们需要修改上述代码如下:
// var matches = splitDate('2015-11-06')
// if (matches === null) {
// return
// }
// var [, year, month, day] = matches
// // 剩余参数rest
// function join(...list) {
// return list.join('--') //添加--
// }
// console.log(join('first', 'second', 'third'))
// separator 就相当于一个默认的参数 占位
// 然后在 输出的时候写就可以了
// function join(separator, ...list) {
// return list.join(separator)
// }
// console.log(join('--', 'first', 'second', 'third'))
// 拓展运算符
// 拓展运算符可以把任意可枚举对象转换为数组,使用拓展运算符可以高效处理目标对象,在拓展目前前添加...就可以使用拓展运算符了。下例中...arguments就把函数的参数转换为了数组字面量。
// function cast() {
// return [...arguments] //剩余参数长度
// }
// console.log(cast('a', 'b', 'c')) //(3) ['a', 'b', 'c']
// 也可以直接单独输出数组 剩余长度
// console.log([...'show me']) //(7) ['s', 'h', 'o', 'w', ' ', 'm', 'e']
// function cast() {
// return ['left', ...arguments, 'right']
// }
// console.log( cast('a', 'b', 'c')) //(5) ['left', 'a', 'b', 'c', 'right']
// var all = [1, ...[2, 3], 4, ...[5], 6, 7]
// console.log(console.log(all)) //(7) [1, 2, 3, 4, 5, 6, 7]
// var [first, second, ...other] = ['a', 'b', 'c', 'd', 'e']
// console.log(other) // <- ['c', 'd', 'e']
// function multiply(left, right) {
// return left * right
// }
// var result = multiply(...[2, 3])
// console.log(result)// <- 6
// function print(...list) {
// console.log(list)
// }
// print(1, ...[2, 3], 4, ...[5])// <- [1, 2, 3, 4, 5]
</script>
</body>
</html> -->
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
</head>
<body>
<script>
// 解构使用示例
// 当一个函数的返回值为对象或者数组时,使用解构,我们可以非常简洁的获取返回对象中某个属性的值(返回数组中某一项的值)。比如说,函数getCoordinates()返回了一系列的值,但是我们只想用其中的x,y,我们可以这样写,解构帮助我们避免了很多中间变量的使用,也使得我们代码的可读性更高。
// function getCoordinates() {
// return { x: 10, y: 22, z: -1, type: '3d' }
// }
// var { x, y } = getCoordinates()
// 通过使用默认值,可以减少重复,比如你想写一个random函数,这个函数将返回一个位于min和max之间的值。我们可以分辨设置min默认值为1,max默认值为10,在需要的时候还可以单独改变其中的某一个值:
// function random({ min = 1, max = 10 } = {}) {
// return Math.floor(Math.random() * (max - min)) + min
// }
// console.log(random())
// // <- 7
// console.log(random({ max: 24 }))
// // <- 18
// 解构还可以配合正则表达式使用。看下面这个例子:
// function splitDate(date) {
// var rdate = /(\d+).(\d+).(\d+)/
// return rdate.exec(date)
// }
// var [ , year, month, day] = splitDate('2015-11-06')
// 不过当.exec不比配时会返回null,因此我们需要修改上述代码如下:
// var matches = splitDate('2015-11-06')
// if (matches === null) {
// return
// }
// var [, year, month, day] = matches
// ----------------------------------
// =====================$
// async function getData(){
// throw new Error ('出错了')
// }
// getData()
// .then(
// v=>console.log(v),
// e=>console.log(e) //Error: 出错了
// )
// async function getData(){
// return new Promise((resolve,rejext) =>{
// setTimeout(()=>{
// var name = 'asss'
// resolve(name)
// },99)
// })
// }
// async function tset(){
// var p= await getData()
// console.log(p)
// }
// tset()//'asss'
// -----------------------------------------------------------
// 没搞懂
// function getEnvelope(type, description) {
// return {
// data: {},
// [type]: description
// }
// }
// console.log(getEnvelope)
// // es6方法定义
// var emitter ={
// events:{
// type:'ajajep'
// },
// on(type, fn) {
// if (this.events[type] === undefined) {
// this.events[type] = []
// }
// this.events[type].push(fn)
// },
// emit(type, event) {
// if (this.events[type] === undefined) {
// return
// }
// this.events[type].forEach(function (fn) {
// fn(event)
// })
// }
// }
// console.log(emitter)
// var timer = {
// seconds: 20,
// start() {
// setInterval(() => {
// this.seconds++
// }, 100)
// }
// }
// timer.start()
// setTimeout(function () {
// console.log(timer.seconds)
// }, 300)
// // <- 3
</script>
</body>
</html>