当前位置: 首页 > news >正文

搜索附近离得近的昆明seo关键字推广

搜索附近离得近的,昆明seo关键字推广,做网站的的人收入多少钱,苏州智能网站开发目录 1,let 和 const1,会产生块级作用域。2,如何理解 const 定义的变量不可被修改? 2,数组3,对象1,Object.is()2,属性描述符3,常用API4,得到除某个属性之外的新对象。 4…

目录

  • 1,let 和 const
    • 1,会产生块级作用域。
    • 2,如何理解 `const` 定义的变量不可被修改?
  • 2,数组
  • 3,对象
    • 1,Object.is()
    • 2,属性描述符
    • 3,常用API
    • 4,得到除某个属性之外的新对象。
  • 4,函数
    • 1,箭头函数
    • 2,默认参数
    • 3,解构传参
    • 4,类语法

js 在 2015年发布了新版本,被称为 es6,之后每年更新一个版本。自 es7 之后,就直接用年份命名了

版本年份
es62015
es72016
es20172017
es20182018

1,let 和 const

1,会产生块级作用域。

if (true) {const a = 1
}
console.log(a) // ReferenceError: a is not defined

下面如果用 var 会打印3个2。

for (let i = 0; i < 3; i++) {setTimeout(function() {console.log(i)}, 1000)
}

2,如何理解 const 定义的变量不可被修改?

指这个变量不能被修改

  • 重新赋值,和修改这个对象的属性值是没有关系的。
const obj = {}obj = 1 // TypeError: Assignment to constant variable.obj.a = 1 // ok
  • 自增
const a = 1
a++ // TypeError: Assignment to constant variable.

2,数组

1,for…of 用于遍历可迭代对象,也包括伪数组,比如 argumentsNodeList(querySelectAll 获取的)

2,判断是不是数组,Array.isArray()

3,解构数组

const arr = [1, 2, 3, 4, 5];const [a, b] = arr; // 1 2
const [, , a, b] = arr; // 3 4
const [a, , b, c] = arr; // 1 3 4
const [a, b, ...c] = arr; // 1 2 [ 3, 4, 5 ]

4,数组去重

const arr = [1, 3, 4, 3, 6];
const newArr = [...new Set(arr)]; // [ 1, 3, 4, 6 ]

5,打平数组

参数为遍历的层级。

const arr1 = [1, 2, [3, 4]];
arr1.flat();
// [1, 2, 3, 4]const arr2 = [1, 2, [3, 4, [5, 6]]];
arr2.flat();
// [1, 2, 3, 4, [5, 6]]const arr3 = [1, 2, [3, 4, [5, 6]]];
arr3.flat(2);
// [1, 2, 3, 4, 5, 6]const arr4 = [1, 2, [3, 4, [5, 6, [7, 8, [9, 10]]]]];
arr4.flat(Infinity);
// [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]

6,创建指定 length 的数组

Array(10).fill(0)

3,对象

1,Object.is()

MDN - Object.is(),判断2个值是否相同,和 === 唯一的区别是:

Object.is(-0, +0) // false
Object.is(NaN, NaN) // true-0 === +0 // true
NaN === NaN // false

Array.prototype.includes() 使用的就是 Object.is() 的规则。

2,属性描述符

js 使用属性描述符,来描述对象中的每个成员。vue2 通过此特性实现响应式核心原理。

const obj = {name: '下雪天的夏风',age: 18
};

在 js 内部被描述为

{// 属性 name 的描述符name: {value: '下雪天的夏风',configurable: true, // 该属性的描述符是否可以被重新定义enumerable: true, // 该属性是否允许被遍历,会影响for-in循环writable: true // 该属性是否允许被修改},// 属性 age 的描述符,同理。age: {value: '18',configurable: true,enumerable: true,writable: true},
}

有 API 可以操作属性描述符

const obj = {name: '下雪天的夏风',age: 18
};// 修改属性描述符
Object.defineProperty(obj, "name", {value: "新值",writable: false,enumerable: false,configurable: true,
});// 获取属性描述符
Object.getOwnPropertyDescriptor(obj, "name");// 输出
{value: '下雪天的夏风',writable: false,enumerable: false,configurable: true
}

1,属性描述符 writable: false 时,修改无效,但不报错。

2,当通过 Object.defineProperty 设置 configurable: false 后,就不能再次修改属性描述符了,会报错。

gettersetter

const obj = {};let init;Object.defineProperty(obj, "a", {get() { // 读取属性 a 时,得到的是该方法的返回值return init;},set(val) { // 设置属性 a 时,会把值传入 val,调用该方法init = val}
});

3,常用API

const obj = { name: "名字", age: "年龄" };
console.log(Object.keys(obj)); // [ 'name', 'age' ]
console.log(Object.values(obj)); // [ '名字', '年龄' ]
console.log(Object.entries(obj)); // [ [ 'name', '名字' ], [ 'age', '年龄' ] ]

还有一个,正好和 Object.entries() 相反。

const obj = Object.fromEntries([["name", "名字"],["age", "年龄"],
]); // { name: '名字', age: '年龄' }

4,得到除某个属性之外的新对象。

const obj = {a: 1,b: 2,c: 3,
};const { a, ...newObj } = obj; // newObj { b: 2, c: 3 }//或
const newObj = {...obj}
delete newObj.a

·

4,函数

1,箭头函数

特点

  1. 不能使用new调用
  2. 没有原型,即没有prototype属性
  3. 没有arugments
  4. 没有this

关于原型

普通函数:

在这里插入图片描述

箭头函数:

在这里插入图片描述

关于 arugments :

function fun() {const fun2 = () => {console.log(arguments);};fun2(1, 2);
}
fun(3, 4); // [Arguments] { '0': 3, '1': 4 }

在箭头函数中,可以使用剩余参数代替 arguments

const fun = (a, ...args) => {console.log(a, args); // 1 [ 2, 3, 4 ]console.log(Array.isArray(args)); // true
};
fun(1, 2, 3, 4);

2,默认参数

const fun = (a, b = 1) => {console.log(a, b);
};
fun(1, undefined); // 1 1

3,解构传参

const fun = (config = { page: 1, limit: 10 }) => {console.log(config); // { page: 1 }  { page: 2, limit: 10 }
};// 这样才能使用默认值
const fun = ({ page = 1, limit = 10 } = {}) => {console.log(page, limit); // 1 10 和 2 10
};fun({ page: 1 });fun({page: 2,limit: 10,
});

4,类语法

基础写法:

// 旧的写法
function User(firstName, lastName){this.firstName = firstName;this.lastName = lastName;this.fullName = `${firstName} ${lastName}`;
}
User.isUser = function(u){return u && u.fullName
}
User.prototype.sayHello = function(){console.log(`姓名:${this.fullName}`);
}// es6 等效写法
class User{constructor(firstName, lastName){this.firstName = firstName;this.lastName = lastName;this.fullName = `${firstName} ${lastName}`;}static isUser(u){return u && u.fullName}sayHello(){console.log(`姓名:${this.fullName}`);}
}

继承关系

function Animal(type, name){this.type = type;this.name = name;
}Animal.prototype.intro = function(){console.log(`I am ${this.type}, my name is ${this.name}`)
}function Dog(name){Animal.call(this, '狗', name);
}Dog.prototype = Object.create(Animal.prototype); // 设置继承关系// 新的方式class Animal{constructor(type, name){this.type = type;this.name = name;}intro(){console.log(`I am ${this.type}, my name is ${this.name}`)}
}class Dog extends Animal{constructor(name){super('狗', name); // 调用父级构造函数}
}

以上。

http://www.mmbaike.com/news/107600.html

相关文章:

  • 小程序免费制作平台系统关键词优化公司哪家好
  • 广州网站制作网页聊石家庄seo
  • 网页设计公司员工seo专业技术培训
  • 网投怎么做网站哪个软件可以自动排名
  • wordpress子菜单位置分离沈阳seo关键词
  • 有没有教做化学药品的网站上海推广服务
  • 工程项目网站重庆镇海seo整站优化价格
  • 重庆营销型网站企业官方网站推广
  • 外包网站该怎么做帐小程序流量点击推广平台
  • 贵阳网站外包铁力seo
  • 微信做自己的网站推广途径有哪些
  • 佛山大良网站建设招聘企业网络营销策划方案
  • 顺德网站建设关键词推广优化排名如何
  • 东莞做汽车有没有买票的网站广告公司接单软件
  • 网站建设需求统计表广州网络推广策划公司
  • 广州一建建设集团seo优化百度技术排名教程
  • 如何安装字体wordpress百度快照如何优化
  • 如何做网站卖连接东莞百度推广优化排名
  • 怎么把做的网站发到网上去做运营需要具备什么能力
  • 文化建设的例子链接优化方法
  • 只做英文网站 域名有什么要求广东云浮疫情最新情况
  • 图片网站制作seo黑帽技术有哪些
  • wordpress 定时发布插件seo推广绩效考核指标是什么
  • 深圳外贸seo网站推广怎么找专业的营销团队
  • 博客网站开发源代码关键词排名优化工具
  • 网站开发需要什么百度图片收录提交入口
  • 有代源码怎么做自己网站百度关键词网站排名优化软件
  • 网站申请免费seo网页优化培训
  • 网站开发的形式品牌词优化
  • 做网站 零基础从哪里开始学快速提升网站关键词排名