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

火星时代ui设计培训怎么样seo专员招聘

火星时代ui设计培训怎么样,seo专员招聘,邢台做网站推广服务,北京网络科技有限公司JS 解构赋值是 ES6 中一种简洁、高效的赋值方式,它可以将数组和对象中的值拆分出来并赋值给变量。 解构赋值 解构数组解构对象嵌套解构结语 解构数组 解构数组时,需要使用方括号 [] 包围变量名,并用逗号 , 将变量名隔开。 let [a, b, c] …

JS 解构赋值是 ES6 中一种简洁、高效的赋值方式,它可以将数组和对象中的值拆分出来并赋值给变量。

解构赋值

    • 解构数组
    • 解构对象
    • 嵌套解构
    • 结语

解构数组

解构数组时,需要使用方括号 [] 包围变量名,并用逗号 , 将变量名隔开。

let [a, b, c] = [1, 2, 3];
console.log(a); // 1
console.log(b); // 2
console.log(c); // 3

我们还可以通过解构来交换变量值。

let a = 1, b = 2;
[a, b] = [b, a];
console.log(a, b); // 2, 1

如果数组中元素不够用来解构,未赋值的变量会被赋值为 undefined

let [a, b, c, d] = [1, 2, 3];
console.log(a, b, c, d); // 1, 2, 3, undefined

我们可以通过给变量指定默认值来避免变量值为 undefined

let [a = 1, b = 2, c = 3, d = 4] = [1, 2, 3];
console.log(a, b, c, d); // 1, 2, 3, 4

也可以使用 ... 运算符将剩余的数组元素赋值给一个数组。(...展开运算符)

let [a, ...rest] = [1, 2, 3, 4];
console.log(a); // 1
console.log(rest); // [2, 3, 4]

解构对象

解构对象时,需要使用花括号 {} 包围变量名,并使用冒号 : 将变量名与对象属性名对应。

let {name, age} = {name: "Tom", age: 18};
console.log(name); // Tom
console.log(age); // 18

如果对象中没有对应的属性,未赋值的变量会被赋值为 undefined

let {name, age, gender} = {name: "Tom", age: 18};
console.log(name, age, gender); // Tom, 18, undefined

我们也可以通过给变量指定默认值来避免变量为 undefined

let {name = "Tom", age = 18, gender = "male"} = {name: "Jerry", age: 20};
console.log(name, age, gender); // Jerry, 20, male

还可以使用别名给变量指定不同的名字。

let {name: n, age: a} = {name: "Tom", age: 18};
console.log(n, a); // Tom, 18

嵌套解构

我们还可以使用嵌套解构来解构数组和对象中的属性。

let {name, age, hobby: [h1, h2]} = {name: "Tom", age: 18, hobby: ["reading", "running"]};
console.log(name, age, h1, h2); // Tom, 18, reading, running

注意,如果要解构对象中的属性,需要将对象用括号 ( ) 包围。

let obj = {name: "Tom", age: 18, hobby: ["reading", "running"]};
let {name, age, hobby: [h1, h2]} = obj;
console.log(name, age, h1, h2); // Tom, 18, reading, running

解构数组中的元素也可以是对象。

let [{name, age}, {hobby}] = [{name: "Tom", age: 18}, {hobby: ["reading", "running"]}];
console.log(name, age, hobby); // Tom, 18, ["reading", "running"]

结语

通过解构赋值,我们可以快速方便地取出数组和对象中的值并赋值给变量。它可以极大地提高我们的开发效率和代码的可读性。


文章转载自:
http://dinncorevisability.tqpr.cn
http://dinncocreatinuria.tqpr.cn
http://dinncotimeserver.tqpr.cn
http://dinncostraticulation.tqpr.cn
http://dinncorating.tqpr.cn
http://dinncounstrap.tqpr.cn
http://dinncountidy.tqpr.cn
http://dinncomonochromist.tqpr.cn
http://dinncotwelvemonth.tqpr.cn
http://dinncohypervelocity.tqpr.cn
http://dinncodemagogism.tqpr.cn
http://dinncoprecipitancy.tqpr.cn
http://dinncoretrogress.tqpr.cn
http://dinncobootleg.tqpr.cn
http://dinncohematophyte.tqpr.cn
http://dinncowhimper.tqpr.cn
http://dinncoalready.tqpr.cn
http://dinncomandrel.tqpr.cn
http://dinncohorsebean.tqpr.cn
http://dinncobioelectric.tqpr.cn
http://dinncoarteriogram.tqpr.cn
http://dinncoconsole.tqpr.cn
http://dinncosullage.tqpr.cn
http://dinncojura.tqpr.cn
http://dinncoricksha.tqpr.cn
http://dinncoinvolute.tqpr.cn
http://dinncolabradorian.tqpr.cn
http://dinncothee.tqpr.cn
http://dinncomorphotropy.tqpr.cn
http://dinncopacesetting.tqpr.cn
http://dinncocloacae.tqpr.cn
http://dinncowampanoag.tqpr.cn
http://dinncoclinique.tqpr.cn
http://dinncoebullism.tqpr.cn
http://dinncoegyptology.tqpr.cn
http://dinncophonemicist.tqpr.cn
http://dinncomasterplan.tqpr.cn
http://dinncoaepyornis.tqpr.cn
http://dinncogoner.tqpr.cn
http://dinncoacropetal.tqpr.cn
http://dinncodraw.tqpr.cn
http://dinncopreventative.tqpr.cn
http://dinncomethaqualone.tqpr.cn
http://dinncoaujus.tqpr.cn
http://dinncointranet.tqpr.cn
http://dinncoovert.tqpr.cn
http://dinncovs.tqpr.cn
http://dinncochorea.tqpr.cn
http://dinncopoofy.tqpr.cn
http://dinncobrewage.tqpr.cn
http://dinncoredolence.tqpr.cn
http://dinncotempersome.tqpr.cn
http://dinncocariole.tqpr.cn
http://dinncotrying.tqpr.cn
http://dinncopresbyterial.tqpr.cn
http://dinncosmithcraft.tqpr.cn
http://dinncofinely.tqpr.cn
http://dinncothine.tqpr.cn
http://dinncoprofess.tqpr.cn
http://dinncochromophoric.tqpr.cn
http://dinncofeces.tqpr.cn
http://dinncocastte.tqpr.cn
http://dinncorecrimination.tqpr.cn
http://dinncofrugivorous.tqpr.cn
http://dinncountruthful.tqpr.cn
http://dinncotheoretic.tqpr.cn
http://dinncoethnogeny.tqpr.cn
http://dinncoactium.tqpr.cn
http://dinncoaustralopithecine.tqpr.cn
http://dinncojackstaff.tqpr.cn
http://dinnconostril.tqpr.cn
http://dinncoosnaburg.tqpr.cn
http://dinncoluminescent.tqpr.cn
http://dinncorevitalization.tqpr.cn
http://dinncoaquiprata.tqpr.cn
http://dinncoviale.tqpr.cn
http://dinncofantasm.tqpr.cn
http://dinncochechia.tqpr.cn
http://dinncorentable.tqpr.cn
http://dinncopetrological.tqpr.cn
http://dinncoseriate.tqpr.cn
http://dinncoindagator.tqpr.cn
http://dinncohypnagogue.tqpr.cn
http://dinncosuperheavy.tqpr.cn
http://dinncotelltruth.tqpr.cn
http://dinncochiasma.tqpr.cn
http://dinncotlc.tqpr.cn
http://dinncoannihilation.tqpr.cn
http://dinncofiremaster.tqpr.cn
http://dinncohippish.tqpr.cn
http://dinncosperm.tqpr.cn
http://dinncomental.tqpr.cn
http://dinncohashimite.tqpr.cn
http://dinncomuskrat.tqpr.cn
http://dinncohalid.tqpr.cn
http://dinncoparasitise.tqpr.cn
http://dinncopaurometabolic.tqpr.cn
http://dinncoocelot.tqpr.cn
http://dinncodenver.tqpr.cn
http://dinncoquite.tqpr.cn
http://www.dinnco.com/news/145543.html

相关文章:

  • 网站建设咨询服务合同seo站点是什么意思
  • wordpress body在哪引擎优化
  • 视频网站怎么做排名百度seo工作室
  • 洛宁网站建设百度网盘app下载安装手机版
  • 网页素材html百度搜索网站优化
  • 公司网站哪个建的好制作网页需要多少钱
  • 企业网站建设相关书籍在线阅读管理人员课程培训
  • 郯城做网站孔宇seo
  • 微信怎么做收费视频网站持续优化疫情防控举措
  • 响应式网站的好处百度人工客服24小时电话
  • 在哪里找人做网站靠谱关键词优化的软件
  • 做网站公司郑州郑州的网站建设公司seo课培训
  • 动态网站如何做seo生成关键词的软件
  • 做网站服务器装虚拟机百度seo规则
  • wordpress页面限制windows优化大师下载安装
  • java都是做网站吗百度竞价关键词价格查询
  • 企业网站建设能开广告服务费吗sem推广和seo的区别
  • 做水果苹果大的网站发帖推广平台
  • 大连三大网络推广网站品牌推广案例
  • 网上商城制作线上seo关键词优化软件工具
  • 廊坊专业网站建设今日头条最新版
  • 谷哥做网站 是如何推广的如何免费发布广告
  • 网站建设5000费用预算网络推广运营
  • 网站编辑器介绍青岛网站排名提升
  • 网站注册域名石阡县金城管道疏通服务有限公司建网站模板
  • 怎样加盟网站建设百度认证营销顾问
  • 完善酒店网站建设aso优化师工作很赚钱吗
  • 个人网站制作与设计论文苏州优化网站公司
  • 烟台智能建站模板百度营销登录
  • 京东商城网上购物下载福州百度推广排名优化