Javascript
文章平均质量分 74
JS相关知识
zyan_cn
这个人很懒,什么也没有写。
展开
-
Eslint配置
Eslint配置1. 基础规则配置{ "rules": { "semi": ["error", "always"], "quotes": ["error", "doublbe"] }}规则semi的第一个值可选值为:"off" or 0 关闭规则"warn" or 1 警告"error" or 2 报错2. 配置继承规则{ "extends": "eslint:recommended"}3. ESlint配置配置Eslint规则的两种方式:通过原创 2021-11-09 17:40:15 · 988 阅读 · 0 评论 -
理解原型对象
理解原型对象1. prototype一个函数一旦创建,就会根据特定的规则为其创建一个prototype属性(指针),指向函数的原型对象。该原型对象在创建时自动获得一个constructor属性,该constructor指向prototype所在函数。即:Person.prototype.constructor === PersonPerson.prototype = { constructor: Person // 自动生成的 prototype样子}2. __proto__当调用构造函原创 2021-06-07 18:09:19 · 225 阅读 · 0 评论 -
创建对象的几种模式
对象字面量的方式不能量产“同类”对象。1. 工厂模式function createPerson(name, age, job) { var o = new Object() o.name = name o.age = age o.job = job o.printName = function() { console.log(this.name); } return o}var person1 = createPerson('Richard', 21, 'Eng原创 2021-06-07 17:00:00 · 180 阅读 · 0 评论 -
common ways to iterate through array
遍历数组的几种方法forconst arr = [1, 2, 3, 4, 5]for(let i = 0; i < arr.length; i++) { console.log(i, arr[i])}for-in// 数组for(let index in arr) { console.log(i, arr[i])}// emumerable objconst obj = { a:1, b:2, c:3, d: 'hello'}for(let prop in obj)原创 2020-10-29 20:46:45 · 84 阅读 · 0 评论