[ES6] Objects Create-shorthand && destructuring

Source: Internet
Author: User

Creating Object:

Example 1:

Let name = "Brook"= 249= "/users/avatars/brook-user-1.jpg"= {name, totalreplies, Avatar };addusertosidebar (user);

Example 2:

function Buildmetadata (object) {  = parseint (object.id);   = Object.updatedat | | Object.createdat;   = _buildhashcode (object);   = +;       return {     id,     lastupdatedat,     hashcode,    Issecurehash () {      return hashcode >= Issecurehash;}}  ;}

Example 3:

function buildtopicelement (topic) {  = ' return {title, author, Body};}

Object destructuring:

 function   Buildmetadata (object) {Let ID   = parseint (object.id); Let lastupdatedat  = Object.updatedat | |   Object.createdat;  Let hashcode  = 16;      Const Issecurehash  = 32;  return   "OK" );     return  hashcode >= Issecurehash; }  };} Let id  = 12" Firday ", obj = = 

From the code, we can see, besides object, you can also destructuring function from the object.

[ES6] Objects Create-shorthand && destructuring

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.