8000 JavaScript 基础系列之对象属性简写 · Issue #84 · yuanyuanbyte/Blog · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

JavaScript 基础系列之对象属性简写 < 9E3E span class="f1-light color-fg-muted">#84

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
yuanyuanbyte opened this issue Nov 22, 2021 · 0 comments
Open

JavaScript 基础系列之对象属性简写 #84

yuanyuanbyte opened this issue Nov 22, 2021 · 0 comments

Comments

@yuanyuanbyte
Copy link
Owner
yuanyuanbyte commented Nov 22, 2021

本系列的主题是 JavaScript 基础,每期讲解一个技术要点。如果你还不了解各系列内容,文末点击查看全部文章,点我跳转到文末

如果觉得本系列不错,欢迎 Star,你的支持是我创作分享的最大动力。

ES6 对象属性简写

在ES6中允许我们在设置一个对象的属性的时候不指定属性名。

不使用ES6:

const name='Ming',age='18',city='Shanghai';
   
const student = {
    name:name,
    age:age,
    city:city
};
console.log(student);//{name: "Ming", age: "18", city: "Shanghai"}

对象中必须包含属性和值,显得非常冗余。

使用ES6:

const name='Ming',age='18',city='Shanghai';
  
const student = {
    name,
    age,
    city
};
console.log(student);//{name: "Ming", age: "18", city: "Shanghai"}

对象中直接写变量,非常简洁。

查看全部文章

博文系列目录

  • JavaScript 深入系列
  • JavaScript 专题系列
  • JavaScript 基础系列
  • 网络系列
  • 浏览器系列
  • Webpack 系列
  • Vue 系列
  • 性能优化与网络安全系列
  • HTML 应知应会系列
  • CSS 应知应会系列

交流

各系列文章汇总:https://github.com/yuanyuanbyte/Blog

我是圆圆,一名深耕于前端开发的攻城狮。

weixin

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant
0