简单的解构赋值
Posted bao2333
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了简单的解构赋值相关的知识,希望对你有一定的参考价值。
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta http-equiv="X-UA-Compatible" content="ie=edge"> <title>Document</title> </head> <body> <script> // const arr = [1,2,3,4] /* const a = 1 const b = 2 const c = 3 const d = 4 */ // const [a, c, b, d] = [1, 2, 3, 4] // const age = 20 function fn(callback) { callback({a: 10, b: 20}) } fn(function ({a, b}) { console.log(a, b) }) // const {a, b} = {a: 10, b: 20} function fn (context) {} fn ({commit}) // content = store = {commit: function () {}, state: {}} const {commit, state} = context const {age: age1, name} = {name: ‘张三‘, age: 18, sex: ‘男‘} </script> </body> </html>
以上是关于简单的解构赋值的主要内容,如果未能解决你的问题,请参考以下文章