ES6~ES10

ES6~ES10新增功能arrayBuffer、decorator、函数式编程 (3)DataView视图:可以自定义复合格式的视图,比如第一个字节是 Uint8(无符号 8 位整数)、第二、三个字节是 Int16(16 位整数)、第四个字节开始是 Float32(32 位浮点数)等等,此外还可以自定义字节序。(2)TypedArray视图:共包括 9 种类型的视图,比如Uint8Array(无符号 8 位整数)数组视图, Int16Array(16 位整数)数组视图, Float32Array(32 位浮点数)数组视图等等。zip操作将两个队列的成员,一一配对,合成一个新的队列。 阅读详情

环境准备
构建:通过webpack babel把es6等转换为es5,让浏览器能识别
node开发环境 gitBash
vsCode插件
Beautify 代码格式化
ESLint 检查
作用域
全局作用域
var a=123 定义变量,不可以被删除
a=123 定义window的属性 可以delete,delete a 返回 true(隐式全局变量)
函数作用域
块状作用域 let const { let a=1 } 不可以通过window.a访问(全局对象的属性)
动态作用域 test.bind({a:100})() 转变test的this指向
词法作用域
ES5数组遍历
for循环
arr.forEach() : 不支持break和continue
arr.every() : 默认return false 需要return true才能接着循环遍历;也可以通过return false代替break中断循环
for in : 为对象设置 ,支持break和continue , 可以设置arr.a=0 数组的下标不应该是字符串 ,是for in 的瑕疵
ES6数组遍历
为遍历自定义数据结构:

const Price={
  A:[1.5,2.3,4.5],
  B:[3,4,5],
  C:[0.5,0.8,1.2]
}

for of
Array.from(arrayLike.mapFn,thisArg
伪数组:按照索引存储数据,有length属性,只能foreach和for遍历
集合调用不了数组的API
ES6已经废弃arguments
ES5: let imgs=[].slice.call(document.querySelectorAll(‘img’))
ES6: let imgs=Array.from(document.querySelectorAll(‘img’))
新生成数组
let arr=Array.from({length:5},function(){ return 1})
let array=Array.of(1,2,3,4,5)
let array=Array(5).fill(7) //array.fill(8,2,4)) array.fill(value,start,end)
Array.from(‘foo’)
Array.from([1,2,3],x=x+x))
filter和find
filter 返回符合的所有的值的数组
find 返回符合的第一个值
findIndex 返回符合的第一个值的下标
类
修改原型链的方法
Animal.prototype.eat=function(){}
let monkey=new Animal()
monkey.constructor.prototype.eat=function(){} //改eat一起改
ES6:
class Animal{ constructor(type){ this.type=type } get age(){ return _age } //只读 set age(val){ if(val<7 && val>4){ _age=val } //写,可以做拦截 eat(){ console.log('eat food') } }
静态方法属于定义的类,拿不到当前的实例对象
实现继承
let dog=function(){
Animal.call(this,‘dog’)
}
dog.prototype=Animal.prototype
ES6:
class Dog extends Animal{
constructor(type){
super(‘dog’)
this.age=2
}
}
Default Parameters 函数默认值
function f(a,y=7,z=x+y){
console.log(f.length) // 定义时不是默认值的参数
return x10+z
}
Rest Parameter
function sum(base,…nums){
let num=0
nums.forEach(function(item){
num+=item
1
}
return base*2+num
}
console.log(sum(1,2,3))
Spread Oprator
function sum(x=1,y=2,z=3){
return x+y+z
}
let data=[4,5,9]
console.log(sum(…data))
箭头函数
let hello=name=>{
console.log(‘hello’,name)
}
只有一个参数并且不是对象,可省略()
箭头函数=>后面的表达式就是返回值
如果返回值是对象,不可以省略{}
Object Property
键值对简写
键可以是表达式,用【】括起来:[x+y]:6
Set数据结构
let s=new Set()
s.add(‘hello’).add(‘bye’).add(‘hello’) //会过滤重复数据
s.clear()
s.has(‘hello’)
s.size
s.keys() s.values()
s.entries() //拿到所有键值对
Map数据结构
Map键值可以是任意值,Map和Set都是可以遍历的
let map = new Map()
let map=new Map([[1,2],[2,3]] //1是键,2是值
map.set(1,2) //可以添加和修改
map.delete(1) //删除索引1的数据
map.clear()
map.size
map.has(1) //按索引值查找
map.get(1)
map.keys() map.values() map.entries()
for(let [key,value] of map){}
Object.assign
Object.assign(target,source) //浅拷贝 如果是对象,拷贝的是地址
Regexp Sticky修饰符(y修饰符)
let s=‘aaa_aa_a’
r1=/a+/g
r2=/a+/y //粘连,只能第一个匹配连续匹配
r1.exec(s) //aaa
r2.exec(s) //aa
r1.exec(s) //4
r2.exec(s) //null
RegExp Updates(u修饰符)
当一个字符
字符串有中文,要加u
`javascript
let s=‘告’
let s2 = ’ \ uD842\uDFB7 ’
console. log( /^\uD842/. test(s2))
console. log( /^\uD842/u. test(s2))

^起始 $结束
**判断**
多个判断,两种简便方法
```javascript
var flag= c!==a && c!==b
if(![a,b].includes(c)){} //includes可以用在数组和字符串
if(flag)

模板字符串
const str=my age is ${a+b} i love ${c}
可以处理换行

let s1=`我是第一行
我是第二行`

函数,包含逻辑运算

function Price(strings,type){
  let s1=strings[0]
  const retailPrice=20
  const wholeSailePrice=16
  let showTxt
  if(type==='retail'){
  	showTxt='购买单价是:'+retailPrice
  }else{
    showTxt='购买的批发价是'+wholeSalePrice
  }
  return `${s1}${showTxt}`
}
let showTxt=Price`您此次的${retail}`
console.log(showTxt)

Array Destructure 数组解构赋值
let [firstName,lastName]=arr

let [first,last]=new Set([1,2,3,4])

let user={name:‘s’,surname:‘t’};
[user.name,user.surname]=[1,2]

let user={name:‘s’,surname:‘t’} //循环体赋值
for(let [k,v] of Object.entrier(user)){ //把user变成可遍历
}

let [first=‘hello’,last,…last]=arr //让别的不被使用的数据不被回收,给first做默认值赋值
Object Destructor对象解构赋值

let options={
 title:'menu',
 width:100,
 height:200
}
let {title:title2,width,height,radiu=2}=options
console.log(title2,width,height)

嵌套:左右结构要一致

let options={
  size:{
    width:200
    height:100
  }
  item:['Cake','Dount'],
  extra:true
}
let {size:{width:width2,height},items:[,item2],extra}=options

Callback(异步操作)
回调地狱:a回调b,b回调c

function loadScript(src,callback){
  let script=document.creatElement('script')
  script.src=src
  script.onload=()=>{callback(src)}
  script.onerr=(err)=>{callback(err)}
  document.head.append(script)
}
function test(){
  console.log('test')
}
loadScript('./1.js,test)

Promise

//pending->fulfilled/reject  (状态转变不可逆)
//promise.then(onFulfilled,onRejected) 这两个参数都是方法
//.then返回一个新的Promise对象,因此可以链式调用原型上的then方法

function loadScript(src){
//pending,undefined
  return new Promise((resolve,reject)=>{
    let script=document.creatElement('script')
    script.src=src
    script.onload=()=>resolve(src) //fulfilled,result
    script.onerror=(err)=>reject(err)//rejected,error
    document.head.append(script)
  })
}
loadScript('./1.js')
 .then(()=>{
   return loadScript('./4.js')  //不加return,就算报错也会执行3.js
 },(err)=>{
   console.log(err)
 })
 .then(()=>{
   loadScript('./3.js')
 },(err)=>{
   console.log(err)
 })

Resolved/Rejected
通过resolve(10)传入一个数值,执行.then()

function test(bool){
  if(bool){
    return new Promise((resolve,reject)=>{
      resolve(30)
    })
  }else{
    return Promise.reject(new Error('ss'))
    // return Promise.resolve(10)
  }
}
test(0).then((value))=>{
  console.log(value)
},(err)=>{
  console.log(err)
})

Catch(异步操作)

loadScript('./1.js')
 .then(()=>{
   return loadScript('./4.js') 
 })
 .then(()=>{
   return loadScript('./3.js')
 })
 .catch(err=>{
   console.log(err)
 })

All(异步操作)
全到

const p1=Promise.resolve(1)
const p2=Promise.resolve(2)
const p3=Promise.resolve(3)
Promise.all([p1,p2,p3]).then((value)=>{
  console.log(value)
})

Race(异步操作)
先到先得

const p1=()=>{
  return Promise((resolve,reject)=>{
    setTimeout(function(){
      resolve(1)  
    },3000)
  })
}
const p2=()=>{
  reutrn Promise(resolve,reject)=>{
    setTimeout(function(){
      resolve(2)
    },0)
  }
}
Promise.race([p1(),p2()]).then((value)=>{
  console.log(value)
})

finally

const Gen =(time)=>{
  return new Promise((resolve,reject)=>{
    setTimeout(function(){
      if(time<500){
        reject(time)
      }else{
        resolve(time)
      }
    },time)
  })
}
Gen(Math.random()*1000)
.then(val=>console.log('resolve',val))
.catch(err=>console.log('reject',err))
.finally(()=>{console.log('finish')})

反射机制
Reflect.apply

console.log(Reflect.apply(Math,null,[4.72]))
//console.log(Math.floor.apply(null,[4.72])
console.log(Reflect.apply(price>100?Math.floor:Math.ceil,null,[price]))

Reflect.construct

let d=Reflect.construct(Date,[])  //相当于new
console.log(d.getTime())
//增加值
const student={}
const r=Reflect.defineProperty(student,'name',{value:'Mike2'}  // r是true
//const r=Object.defineProperty(student,'name',{value:'Mike2'} r是修改后的student
//删除值
const obj={x:1,y:2}
console.log(Reflect.delete(obj,'x')
//获取值
Reflect.get(obj,'x')
Reflect.get([3,4],1)
Reflect.getOwnPropertyDescriptor(obj,'y')) //看他的值,是否可扩展等
Reflect.getPrototypeOf(d) //看原型上的方法
Reflect.has(obj,'x') //验证对象上有没有属性 Object没有这个方法
Reflect.isExtensible(obj) //验证是否可拓展 如果Object.freeze(obj)/preventExtensions(obj)之后 , 这个方法返回false
Reflect.ownKeys(obj) //返回对象的值
Reflect.set(obj,'z',4) //赋值操作,写
Reflect.setPrototypeOf(arr,String.prototype) //修改原型对象

Proxy代理
https://blog.youkuaiyun.com/weixin_45195200/article/details/100113005

//中介排序
let o={
  name:'Xiaoming',
  price:190
}
let d=new Proxy(o,{
  get(target,key){
   if(key==='price'){
     return target[key]+20
   }else{
     return target[key]
   }
 }
})
console.log(d.price,d.name)
//拦截修改,用户拦截
let d= new Proxy(o,{
  get(){}
  set(target,key,value){
    return false
  }
}
//es5 Object.defineProperty(o,key,{writable:false})

//可撤销
let d=Proxy.revocable(o,{})
d.revoke() //撤销

//监听错误,上报
window.addEventListener('error',(e)=>{
  console.log(e.message)
  report('./')
},true)
//校验规则
let validate=(target,key,value)=>{
  if(Reflect.has(target,key)){
    if(key==='price'){
      if(value>300){
        throw new TypeError('price exceed 300')
       }else{
         target[key]=value
        }
      }else{
        target[key]=value
      }
    }else{
      return false
    }
}
let d=new Proxy(o,{
  get(target,key){
    return target[key]||''
  },
  set:validator
})
//2
class Component {
constructor () {
this.proxy = new Proxy({ 
 id:Math.random().toString(36).slice(-8)
}, {})
}
get id(){
  return this.proxy.id
}
}
let com = new Component( )
let com2 = new Component( )
for(let i=0;i<10;i++){
console. log(com. id, com2. id)
}

Generator函数

function * gen () {
  let val
  val=yield * [1,2,3]
  console. log(val)
}
console. log(l.next())
//next返回遍历和done:true/false
g.throw(new Error('ss')//抛出异常
g.return()

场景模拟 抽奖
依次输出第一二三等奖,并保证不重复

while(1){
  if(count<first){
    random = Math.floor(Math.random()*firstPrise.length)
    yield firstPrise[random]
    firstPrice.splice(random,1)
  }else if{ count<first+second){
    random=Math.floor(Math.random()*secondPrise.length)
    yield secondPrise[random]
    second.splice(random,1)
 }else if(count<first+second+third){
   random=Math.floor(Math.random()*thirdPrise.length)
   yield thirdPrise[random]
 }else{
   return false
 }
}
console.log(dom().next().value())

Iterator迭代器
自定义遍历
需要有iterator,有next()函数next里面有{done value}

let authors = {
  allAuthors: {
    fiction: [ 'Agla','Skks','LP'],
    scienceFiction: [ 'Neal', 'Arthru', 'Ribert'],
    fantasy: ['J.R.Tole', 'J.M.R', 'Terry P.K']
  },
  Address: []
}
//遍历器接口
authors[Symbol.iterator]=function(){
  let allAuthors=this.allAuthors
  let keys = Reflect.ownKeys(allAuthors)
  let values=[]
  return{
    next(){
      if(!values.length){
        if(keys.length){
          values=allAuthors[keys[0]]
          keys.shift()
        }
      }
      return {
        done:!values.length, //说明遍历是否结束
        value:values.shift() //遍历得到的值
      }
    }
  }
}
let r=[]
for(let v of authors){
  r.push(v)
}
console.log(r)

Export Import 模块化
export default 默认导出,只能一个

import name2 from ‘’ 可以重新起名字
import {addr as arr2} from’’ 不是默认变量的话可以重新起名字

export default{data,des}
import obj from ‘’
let {data,des}=data

export classText{}
export default class text{}
import * as Mod from ‘’
let people = new Mod.default()
console.log(people.id)

include +pow
2 ** 5 / Math.pow(2,5)
arr.includes(4)

Async_Await
async返回一个promise对象,对象状态是resolved
await 只能在async中用,返回promise 传入的不是promise 的话,会自动转化伪promise.resolved()
快速遍历Object.keys.values.entries
Object.keys(grade).filter(item=>item===‘lilei’)
Object.values(grades).filter(item=>item>96)
for(let [k,v] of Object.entries(grade)){}

String Padding 字符串补白
for(let i=1;i<32000;i++){
console.log(i.toString().padStart(5,’*#’) //往后补:padEnd
}

Object.getOwnDescriptor描述符
对数据的操作 enmurable/writable
**for await of **
异步迭代器 Async Iterrator
使用Symbol.asyncIterator作为key
异步迭代器必须返回promise对象 且Promise 返回{value,done}
搭配使用for- await -of

// function Gen(time){
//   return new Promise((resolve,reject)=>{
//     setTimeout(function(){
//       resolve(time)
//     },time)
//   })
// }
// async function test(){
//   let arr=[Gen(2000),Gen(100),Gen(3000)]
//   for await (let item of arr){
//     console.log(Date.now(),item)
//   }
// }
// test()
const obj ={
  count:0,
  Gen(time){
    return new Promise((resolve,reject)=>{
      setTimeout(function(){
        resolve({done:false,value:time})
      },time)
    })
  },
  [Symbol.asyncIterator](){
    let self=this
    return{
      next(){
        self.count++
        if(self.count<4){
          return Gen(Math.random()*1000)
        }else{
          return Promise.resolve({
            done:true,
            value:''
          })
        }
      }
    }
  }
}
async function test(){
  for await(let item of obj){
    console.log(Date.now(),item)
  }
}

正则

//dotAll
//.匹配任意字符,但是不匹配换行符之类,可以用dotAll 后面加s
console.log(/foo.bar)/us.test('foo\nbar') //u是匹配中文字符
console.log(re.dotAll) //判断re是否用了dotAll 或者 re.flags
//命名分组匹配
const t='2019-06-07'.match(/(?<year>\d{4})-(?<month>\d{2}-(?<day>\d{2}))
console.log(t.groups.year)
//先行|后行断言
//先遇到一个条件再接着判断:先行断言
let test='hello world'
console.log(test.match(hello(?=/sworld)/))
//遇到往前走:后行断言
console.log(test.match(/(?<=hello\s)world/)

ES10新增

console.log(JSON.stringify('\u{D800}')) //JSON.stringify() 方法用于将 JavaScript 值转换为 JSON 字符串。
let arr=[1,[2,3],[4,5,[6,7]]]
console.log(arr.flat(3))  //arr.flat(depth)
arr.flatMap(item=>[item*2])
str.trimStart()/str.trimLeft() //去除首部空格
str.trimRight()/str.trimEnd() //去除尾部空格
str.trim()//
str.matchAll(regExp) //匹配所有结果

const arr=[['foo',1],['bar',2]]
const obj=Object.fromEntries(arr) //Object.fromEntries() 方法把键值对列表转换为一个对象。
console.log(obj)

const obj={
  abc:1,
  def:2,
  ghs:3
}
let res=Object.fromEntries(
  Object.entries(obj).filter(([key,val])=>key.length===3)//转化为数组,可以调用数组的api,Object.entries()方法返回一个给定对象自身可枚举属性的键值对数组
)
console.log(res)

vue
vue指令

import Vue from 'vue
Vue.directive('make-res',{
  inserts:(el){
    el.style.color='red'
  }
}
代理配置
module. exports = {
  devServer: {
  proxy: {
    ' /user': {
      target: ' http:// localhost :8081' ,
      pathRewrite: {
       ' /user': 'user. json'
      }
    },
    ' /list': {
      target: ' http:// localhost:8081',
      pathRewrite: {
        '/list': 'list. json'
      }
    }
    }
  }
}

解构赋值

async mounted(){
  count{data:{list}}=await axios.get('/list')
  this.$data.list=list
}
}

navigator.language
代理proxy

methods:{
  up (){ this.price=this.proxy.up},
  down(){this.price=this.proxy.down},
  reset (){this.price=this.proxy.default}
}
async mounted (){
  const {data:{price}}=await axios.get('./proxy')
  Object.freeze(prize)
  this.proxy=new Proxy({},{
    get(target,key){
      if(key === 'up'){
        return [].concat(price).sort((a,b)=>a-b)
      }else if(key === 'down'){
        return [].concat(price).sort((a,b)=>b-a)
      }else{
        return price
      }
    },
    set (){
      return false
    }
  })
  this.price=this.proxy.default
}

自定义遍历

async mounted (){
  const{data:{allAuthors}}=await axios.get('./author')
  const author=new Proxy(allAuthors,{
    has(target,key){
      const keys=Reflect.ownKeys(target).slice(0,-2)
      for(const item of keys){
        if(target[item].includes(key)){
          return true
        }
      }
      return false
    }
  })
  author[Symbol.iterator]=function *(){
    const all=this
    const keys=Reflect.ownKeys(this).slice(0,-2)
    let values=[]
    while(1){
      if(!values.length){
        if(keys.length){
          values=[].concat(all[key[0]])
          keys.shift()
          yield values.shift()
        }else{
          yield values.shift()
        }
      }
    }
  }
  this.authors=allAuthors
}

webpack
本质上, webpack是-个现代JavaScript 应用程序的静态模块打包工具。当webpack处理应用程序时,它会在内部构建一个依赖图(dependency graph),此依赖图会映射项目所需的每个模块,并生成一个或多个bundle。
const path=require(‘path’);
module.exports={
entry:’./…js’
output:{
path:path.resolve(_dirname,‘dist’),
filename:’./.js’
}
modules:{
rules:[
{test:/.txt$/,use:‘raw-loader’}
]
}
plugin:[
new HtmlWebpackPlugin({template:’./.html’})
]
mode:‘production’
}
babel
在这里插入图片描述1.代码解析:相同功能不同语法
2.抽象语法树
3.转换成es5语法树
4.增删代码
5.还原代码(index.min.js)
ESlint
代码检查并格式化
依赖规则,如:Variables规则
每个规则会设置三个检查等级:
●"off"或0-关闭规则
●"warn"或1 -开启规则,使用警告级别的错误: warn (不会导致程序退出)
●"error"或2 -开启规则,使用错误级别的错误: error (当被触发的时候,程序会退出)
eslint:
eslintrc.json
在这里插入图片描述
ES6补充
function a (a=2,b=3){
}
a(undefined,5)

避免输入框攻击
function sanitize(string,…values){
const dirty=strings.reduce((prev,curr,i)=>${prev}${curr}${values[i]||''|,’’);
return DOMPurify.sanitize(dirty);
}
commentDiv.innerHTML=santize`

${{user}
${textarea.value}
` str.startsWith() //大小写敏感 .endWidth(‘aa',10) // .includes() .repeat(5)

循环遍历
for循环,较繁琐
forEach,不支持continue/break
for in ,遍历所有可枚举的值的键,包括属性
for of,得到对象的值

Array.from
function sum(){
return Array.from(arguments).reduce((prec,curr)=>prev+curr,0)
}
Array.of创建固定数组
Array.of(1) //1

回调地狱
Promise axios是promise的

function getReoBuid(id){
  return new Promise((resolve,reject)=>{
    setTimeout(()=>{
      const repo=repos.find(repo => repo.id ===id);
      if(repo){
        resolve(repo)
      }else{
        reject(error('no repo'))
      }
    },2000)
  })
}
function conboundOwner(repo){
  return new Promise((resolve,reject)=>{
    const owner=owners.find(owner=>owner.name===repo.name)
    if(owner){
      resolve(owner)
    }else{
      reject(error('no owner'))
    }
  })
}
getReoBuid(1)
.then(repo=>{
  return conboundOwner(repo)
})
.then(repo=>{
  console.log(repo)
})
.catch(error=>{
  console.error(err)
})

symbol
[Symbol(‘lili’)]:{grade:60,gender:‘male’}
const syms=Object.getOwnPropertySymbol(classRoom).map(sym=>classRoom.sym)

webpack
package.json:
“scripts”:“webpack --progress --watch”
–progress:说明进度 --watch变化
生成用户头像:gravatr

SystemJS

package.json:
“server”:“webpack --progress --watch”

babel
babel-polify : 新增的方法

公用方法:不会每新成一个对象的时候都新生成一个方法:prototype…

let methodName=‘info’;
class User{
constructor(name,email){
this.namee=name;
this.age=age;
}
methodName{}
set github(value){this.gitHub=gutHub}
get gitHub(){return `https://hitHub.com/${this.github}’
}
typeof User:function
static descript(){} 只能在类User上调用,不能在实例上调用

箭头函数不能用auguments

console.table()
排序:this.sort((a,b)=>{a.score>b.score)?-1:1).slice(0,limit)

WeakSet只能是对象
set()
map()

异步
ajax请求
setTimeout(alert是同步,会阻塞)
事件绑定
单线程:一次只能干一件事,遇到异步函数,先暂存起来

日期
var dt=bew Date()
dt.getTime() //获取毫秒数
dt.getFullYear()
dt.getMonth()
dt.getDate()
dt.getHours()
dt.getSeconds()

Math.random() //获取0-1的随机数

forEach() //遍历元素
every()
some()
sort()
map() //对元素重新组装
filter()

遍历对象

var obj={
	name:'lily',
	age:10,
	height:150
}
for(let key in obj){
	if(obj.hasOwnProperty(key){
		cosole.log(key,obj[key])
	}
}
	
ES6~ES10新增功能异步、类Class、模块Module Node.js 对 ES6 模块的处理比较麻烦,因为它有自己的 CommonJS 模块格式,与 ES6 模块格式是不兼容的。在JavaScript中,类的静态属性和静态方法是直接隶属于类本身而不是类的实例的属性和方法。静态方法常用于提供与类相关的工具函数、工厂方法或者与类的初始化、配置相关的逻辑,它们不需要操作实例状态,而是与类作为一个整体的功能相关。新引入的for await…它们是共享的,所有对该类的引用都会访问相同的静态属性。Mixin 指的是多个对象合成一个新的对象,新对象具有各个组成成员的接口。 阅读详情

相关推荐

ES6~ES10数据类型的基础扩展

类似于对象,也是键值对的集合,但是“键”的范围不限于字符串,各种类型的值(包括对象)都可以当作键。Array.from方法用于将两类对象转为真正的数组:类似数组的对象(array-like object)和可遍历(iterable)的对象(包括 ES6 新增的数据结构 Set 和 Map)。数组实例的findIndex方法的用法与find方法非常类似,返回第一个符合条件的数组成员的位置,如果所有成员都不符合条件,则返回-1。而且,返回的正则表达式会忽略原有的正则表达式的修饰符,只使用新指定的修饰符。

天涯学馆 323

babel-polyfill

babel-polyfill Babel默认只转换新的JavaScript句法(syntax),而不转换新的API,比如Iterator、Generator、Set、Maps、Proxy、Reflect、Symbol、Promise等全局对象,以及一些定义在全局对象上的方法(比如Object.assign)都不会转码。 举例来说,ES6在Array对象上新增了Array.from方法。Babe...

weixin_30552635的博客 435

ES6~ES10新增功能proxy、reflect、promise对象、迭代

Reflect对象的方法与Proxy对象的方法一一对应,只要是Proxy对象的方法,就能在Reflect对象上找到对应的方法。现阶段,某些方法同时在Object和Reflect对象上部署,未来的新方法将只部署在Reflect对象上。虽然 Proxy 可以代理针对目标对象的访问,但它不是目标对象的透明代理,即不做任何拦截的情况下,也无法保证与目标对象的行为一致。Proxy.revocable()方法返回一个对象,该对象的proxy属性是Proxy实例,revoke属性是一个函数,可以取消Proxy实例。

天涯学馆 229

es6-es10新增了那些东西

从ES6 到 ES10,JavaScript 引入了许多提升代码可读性、简洁性以及处理复杂异步操作的特性。ES6: 引入了letconst、箭头函数、模块化、Promise、类、模板字符串等。ES7: 引入了和指数运算符**。ES8: 引入了和。ES9: 引入了异步迭代器、。ES10: 引入了和。这些新特性极大地改善了 JavaScript 的语法,增强了开发效率。

HHX_01的博客 1125

从CTFShow靶场实战,聊聊Node.js原型链污染漏洞的几种利用姿势(附详细复现步骤)

本文深入剖析Node.js原型链污染漏洞的原理与实战利用,通过复现CTFShow靶场题目(web338-web341),详细演示五种高级利用技巧,包括基础污染、多级污染、模板引擎RCE等,并提供防御方案与最佳实践,帮助开发者提升Web应用安全性。

weixin_30791095的博客 446

手把手教你用Cesium和RayMarching实现逼真体积云(附完整Shader代码)

本文详细介绍了如何利用Cesium和RayMarching技术实现逼真的体积云效果,包括环境准备、核心逻辑、云层建模和光照增强等关键步骤,并提供了完整的Shader代码。通过噪声函数选型、动态风场模拟和多重散射近似等技术,开发者可以在数字地球可视化项目中创建沉浸式天气效果,显著提升场景的真实感。

weixin_29230649的博客 415

webpack打包高级es语法示例:

默认情况下,webpack打包js不会做任何转换和编译 而至原样输出,所以让浏览器支持es高级语法需要用babel来转换。

qq_36413371的博客 616

VECTOR硬件VN1600系列对比:VN1610、VN1611、VN1630A、VN1640A、VN1630log、VN1670

VN16系列说不清道不明的区别和关系

AmorRun的博客 2万+

什么是Redux?它的核心概念有哪些?

引言Redux 核心概念Store(仓库)State(状态)Action(动作)Reducer(规约器)安装与初始化示例代码示例一:定义 Action示例二:编写 Reducer示例三:合并 Reducers示例四:连接 Store 和组件功能使用思路1. 状态管理2. 异步操作3. 模块化和可测试性实际工作中的使用技巧结语return {return {Redux 为复杂的前端应用提供了一套强大而灵活的状态管理方案。

一个做过前端开发的产品经理,经历过睿智产品的折磨导致脱发之后,励志要翻身"农奴"把歌唱,一边打入敌人内部一边持续提升自己,为我们广大开发同胞谋福祉,坚决抵制睿智产品折磨我们码农兄弟! 1069

ISP图像处理Verilog仿真框架搭建(附代码)

基于Verilog的图像处理仿真框架搭建

路漫漫其修远兮,吾将上下而求索 1896

AI算力瓶颈与系统优化实战指南

AI算力瓶颈已成为制约人工智能发展的关键因素,特别是在处理transformer类模型时,传统的冯·诺依曼架构面临严重的'内存墙'问题。通过硬件加速、系统优化和算法改进的三级策略,可以有效提升资源利用率。在嵌入式AI领域,结合量化、剪枝和专用指令集扩展等技术,能在资源受限设备上实现高效推理。这些优化方法在自动驾驶、工业视觉等场景中已展现出显著价值,推动AI应用从云端向边缘迁移。随着AI算力需求的持续增长,掌握系统优化技能将成为开发者的核心竞争力。

weixin_32597009的博客 339

ES6-10学习笔记

一、ES6 1、全局变量 //两种生成全局变量的方法(都是写在函数体外) var a=123; b=456; //两种方法生成全局变量的区别: //1、 //没有使用 var 生成的全局变量,是作为window的属性存在, //不是真正意义上的全局变量,可以用 delete b (或者delete window.b)删除,删除之后获取b则是 not defind, //而通过 var 生成的全...

qiao 833

无人机——电机篇(一)

1. 电机的定义 电机俗称“马达”,是无人机的动力来源,无人机通过改变电机的转速来改变无人机的飞行状态。即改变每个电机的速度,使得无人机能够盘旋空中,上升或下降,或向各个方向移动。2. 电机的分类 电机分为:“无刷电机”和“有刷电机” - 无刷电机:是采用半导体开关器件来实现电子换向,具有可靠性高、低干扰、低噪声低、寿命长等优点。一般应用在稍大型的飞行器,载重大,可以有更广泛的用途。 - 有刷电机:是内含电刷装置的将电能转换成机械能(电动机)或将机械能转换成电能(发电机)的旋转电机。有刷电机是所有电机的基

weixin_46066938的博客 1万+

es6在原生代码的用法_领略原生 JavaScript ES6~ES10 的魅力

作为前端开发工程师,盲目追逐框架似乎有点舍本逐末,要知道基本功才是硬核。JavaScript 的语法这几年一直在更新,不管我们是框架的核心开发者还是业务重塑者,学习下最新的 JavaScript 语法和能力是非常有好处的。下面我们通过几个小示例来看下新语法的强大之处:“初始化一个数组,要求数组的长度是 5,每个元素的默认值是 0”这道题看似非常简单,我们可能会这样来写代码:const arr = ...

weixin_39747615的博客 129

零基础速成simulink代码生成——stateflow基础3

此专栏面向嵌入式工程没有matlab开发经验的人,可以快速学习和实践这门技术。MDB技术,越来越成熟和普遍,从手写代码转到基于模型开发已经是大势,不仅减少开发周期,还增加代码的复用性。汽车领域、医疗和算法建模广泛使用。

不断debug,优化中…… 1711

PCL Alpha Shapes平面点云边界特征提取【2026最新版】

alpha shapes算法用于平面点云的边界特征提取。博客长期更新,本文最近一次更新时间为:2026年4月20日。

点云侠的博客 27万+

JavaScript与ECMAScript(ES6~ES10)发展和新特性介绍,看这一篇就够了

JavaScript和ES的文章和介绍还是比较多的,但是大部分不够全面和比较老, 我这里结合最新请再梳理总结一下,使用各位大佬的都加了链接,如果有版权问题请联系我修正。 网上各种【看这一篇就够了】,这里名字也俗气一把跟个风吧。 JavaScript是什么 JavaScript(简称“JS”) 是一种具有函数优先的轻量级,解释型或即时编译型的编程语言。 JavaScript 基于原型编程、多范...

liuborama的专栏 737

复分析 阿尔福斯(Ahlfors) 第三版答案 英文

答案分为十章,有部分习题没有答案,全英文复分析阿尔福斯(Ahlfors) 第三版答案

ES6 第二天

``` 内容:ECMAScript基础 日期:xx-xx-xx ``` # 一、...运算符【重点】 ## 1.1 扩展运算符(spread) 1、扩展运算符的语法: ... 2、扩展运算符的功能: 展开数据、收集数据 ### 1.1.1函数传参 ```javascript <script> //收集数据 //function demo(x, y, z) { function demo(...y) { //收集数据 ...

ILove_bugs的博客 305

lwip-2.0.3

lwip是瑞典计算机科学院(SICS)的Adam Dunkels 开发的一个小型开源的TCP/IP协议栈。实现的重点是在保持TCP协议主要功能的基础上减少对RAM 的占用。

深度学习工具包 DeepLearningToolbox

深度学习工具包Deprecation notice.-----This toolbox is outdated and no longer maintained.There are much better tools available for deep learning than this toolbox, e.g. [Theano](http://deeplearning.net/software/theano/), [torch](http://torch.ch/) or [tensorflow](http://www.tensorflow.org/)I would suggest you use one of the tools mentioned above rather than use this toolbox.Best, Rasmus.DeepLearnToolbox================A Matlab toolbox for Deep Learning.Deep Learning is a new subfield of machine learning that focuses on learning deep hierarchical models of data.It is inspired by the human brain's apparent deep (layered, hierarchical) architecture.A good overview of the theory of Deep Learning theory is[Learning Deep Architectures for AI](http://www.iro.umontreal.ca/~bengioy/papers/ftml_book.pdf)For a more informal introduction, see the following videos by Geoffrey Hinton and Andrew Ng.* [The Next Generation of Neural Networks](http://www.youtube.com/watch?v=AyzOUbkUf3M) (Hinton, 2007)* [Recent Developments in Deep Learning](http://www.youtube.com/watch?v=VdIURAu1-aU) (Hinton, 2010)* [Unsupervised Feature Learning and Deep Learning](http://www.youtube.com/watch?v=ZmNOAtZIgIk) (Ng, 2011)If you use this toolbox in your research please cite [Prediction as a candidate for learning deep hierarchical models of data](http://www2.imm.dtu.dk/pubdb/views/publication_details.php?id=6284)```@MASTERSTHESIS\{IMM2012-06284, author = "R. B. Palm", title = "Prediction as a candidate for learning deep hierarchical models of data", year = "2012",}```Contact: rasmusbergpalm at gmail dot comDirectories included in the toolbox-----------------------------------`NN/` - A library for Feedforward Backpropagation Neural Networks`CNN/` - A library for Convolutional Neural Networks`DBN/` - A library for Deep Belief Networks`SAE/` - A library for Stacked Auto-Encoders`CAE/` - A library for Convolutional Auto-Encoders`util/` - Utility functions used by the libraries`data/` - Data used by the examples`tests/` - unit tests to verify toolbox is workingFor references on each library check REFS.mdSetup-----1. Download.2. addpath(genpath('DeepLearnToolbox'));Example: Deep Belief Network---------------------```matlabfunction test_example_DBNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit RBM and visualize its weightsrand('state',0)dbn.sizes = [100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);figure; visualize(dbn.rbm{1}.W'); % Visualize the RBM weights%% ex2 train a 100-100 hidden unit DBN and use its weights to initialize a NNrand('state',0)%train dbndbn.sizes = [100 100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);%unfold dbn to nnnn = dbnunfoldtonn(dbn, 10);nn.activation_function = 'sigm';%train nnopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.10, 'Too big error');```Example: Stacked Auto-Encoders---------------------```matlabfunction test_example_SAEload mnist_uint8;train_x = double(train_x)/255;test_x = double(test_x)/255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit SDAE and use it to initialize a FFNN% Setup and train a stacked denoising autoencoder (SDAE)rand('state',0)sae = saesetup([784 100]);sae.ae{1}.activation_function = 'sigm';sae.ae{1}.learningRate = 1;sae.ae{1}.inputZeroMaskedFraction = 0.5;opts.numepochs = 1;opts.batchsize = 100;sae = saetrain(sae, train_x, opts);visualize(sae.ae{1}.W{1}(:,2:end)')% Use the SDAE to initialize a FFNNnn = nnsetup([784 100 10]);nn.activation_function = 'sigm';nn.learningRate = 1;nn.W{1} = sae.ae{1}.W{1};% Train the FFNNopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.16, 'Too big error');```Example: Convolutional Neural Nets---------------------```matlabfunction test_example_CNNload mnist_uint8;train_x = double(reshape(train_x',28,28,60000))/255;test_x = double(reshape(test_x',28,28,10000))/255;train_y = double(train_y');test_y = double(test_y');%% ex1 Train a 6c-2s-12c-2s Convolutional neural network %will run 1 epoch in about 200 second and get around 11% error. %With 100 epochs you'll get around 1.2% errorrand('state',0)cnn.layers = { struct('type', 'i') %input layer struct('type', 'c', 'outputmaps', 6, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %sub sampling layer struct('type', 'c', 'outputmaps', 12, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %subsampling layer};cnn = cnnsetup(cnn, train_x, train_y);opts.alpha = 1;opts.batchsize = 50;opts.numepochs = 1;cnn = cnntrain(cnn, train_x, train_y, opts);[er, bad] = cnntest(cnn, test_x, test_y);%plot mean squared errorfigure; plot(cnn.rL);assert(er<0.12, 'Too big error');```Example: Neural Networks---------------------```matlabfunction test_example_NNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);% normalize[train_x, mu, sigma] = zscore(train_x);test_x = normalize(test_x, mu, sigma);%% ex1 vanilla neural netrand('state',0)nn = nnsetup([784 100 10]);opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samples[nn, L] = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.08, 'Too big error');%% ex2 neural net with L2 weight decayrand('state',0)nn = nnsetup([784 100 10]);nn.weightPenaltyL2 = 1e-4; % L2 weight decayopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex3 neural net with dropoutrand('state',0)nn = nnsetup([784 100 10]);nn.dropoutFraction = 0.5; % Dropout fraction opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex4 neural net with sigmoid activation functionrand('state',0)nn = nnsetup([784 100 10]);nn.activation_function = 'sigm'; % Sigmoid activation functionnn.learningRate = 1; % Sigm require a lower learning rateopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex5 plotting functionalityrand('state',0)nn = nnsetup([784 20 10]);opts.numepochs = 5; % Number of full sweeps through datann.output = 'softmax'; % use softmax outputopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex6 neural net with sigmoid activation and plotting of validation and training error% split training data into training and validation datavx = train_x(1:10000,:);tx = train_x(10001:end,:);vy = train_y(1:10000,:);ty = train_y(10001:end,:);rand('state',0)nn = nnsetup([784 20 10]); nn.output = 'softmax'; % use softmax outputopts.numepochs = 5; % Number of full sweeps through dataopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, tx, ty, opts, vx, vy); % nntrain takes validation set as last two arguments (optionally)[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');```[![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/rasmusbergpalm/deeplearntoolbox/trend.png)](https://bitdeli.com/free "Bitdeli Badge")

《Javscript实用教程》

图书购买地址:《Javscript实用教程》 目录 Javascript实用教程... 1 目录... 2 第 1 部分... 12 ◄ Javascript基础 ►. 12 第 1 章... 13 ◄ JavaScript 语法基础►. 13 1.1基本概念和开发工具... 13 1.1.1 编程语言... 13 1.1.2 计算机语言... 13 1.1.3 编程语言... 13 1.1.4 翻译器... 14 1.1.5 编程语言和标记语言区别... 14 1.1.6 计.

邹玉杰(邹琼俊)的专栏 1503

Probability and Statistics - 4th edition

Probability and Statistics - 4th edition

js(es7-es10)特性

es6~es10详解 ES7 新特性 1.Array.prototype.includes() 方法 在 ES6 中我们有 String.prototype.includes() 可以查询给定字符串是否包含一个字符,而在 ES7 中,我们在数组中也可以用 Array.prototype.includes 方法来判断一个数组是否包含一个指定的值,根据情况,如果包含则返回 true,否则返回 false。 const arr = [1, 3, 5, 2, '8', NaN, -0] arr.incl

豪哥的博客 1305

ES6语法(Reflect、Proxy、Promise)

ES6 引入了 Promise 对象,它用于异步编程,解决了回调地狱(callback hell)的问题,使得异步操作更加清晰和易于管理。这为开发人员提供了更灵活和强大的能力来控制对象的访问和操作。Promise 对象提供了一种更加优雅和便捷的方式来处理异步操作,使得代码更易读、易维护,同时也提供了丰富的方法来处理异步操作的组合和控制流。Reflect API 提供了一种更加统一和灵活的方式来进行对象操作,同时也为 Proxy 对象的拦截器提供了更多的底层操作支持。

qq_41675930的博客 694

es10~es14

将二维数组,转为对象,一般常用来将map对象,转为对象ES8 中学习的Object.entries 将对象转为二维数组,与Object.fromEntries互为逆运算。

2503_90189180的博客 899

ES6~ES13上篇

在ES6模块中导入CommonJS模块:可以直接使用import导入CommonJS模块,Node.js会自动处理。在CommonJS模块中导入ES6模块:需要使用import()动态导入ES6模块,它返回一个Promise。CommonJS模块是动态加载,require函数可以在代码的任何位置调用,根据运行时的条件决定导入哪个模块。ES6模块是静态加载,在编译阶段就确定模块的依赖关系,不能在运行时动态导入。在实际项目中,可能会遇到需要同时使用ES6模块和CommonJS模块的情况。

2403_88911292的博客 1153

ES6~ES11新特新

作用域var声明的变量具有全局作用域或函数作用域。在全局作用域下,使用var声明的变量会被附加到window对象上。let和const声明的变量具有块级作用域,仅在声明它们的代码块内有效。这意味着它们的作用域被限制在一对花括号内,即一个块内。变量提升var声明的变量会发生变量提升,无论在函数的哪个部分声明,它们都会被移动到函数的顶部。这可能导致预期之外的变量访问行为。let和const声明的变量也会提升,但它们不会被初始化。

weixin_70588154的博客 958

【学习笔记】ES6~ES11

ES6~ES11

Eddie_hyh的博客 755

ES6~ES11新特性

/ 声明一个对象name: "终极一班",stus: ['knight'],// 2. 加上迭代器————迭代器返回的是一个对象————第一次调用对象的 next 方法,指针自动指向数据结构的第一个成员// 索引变量// 在外层声明变量进行保存return {//根据下标决定返回的结果// 每一次调用next方法,都返回的结果就是false,我们需要对返回结果进行处理// 让下标进行自增index++;// 不进行自增 永远为0// 返回结果} else {

walll0929的博客 1237
上一篇: 杂记知识点
下一篇: vue易错
qq_47414739
博客等级 码龄7年 0粉丝 11原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值