ES Learning Notes

Source: Internet
Author: User

Deconstruction Assignment of variables

1. parentheses use

var [(a)] = [1];  //报错,变量声明语句中,不能带有圆括号。
[(a)] = [1];    //正确,模式是取数组的第一个成员,跟圆括号无关。

2. Traverse the map structure

Any object that has the iterator interface deployed can be for...of traversed with loops. The map structure natively supports the iterator interface, and it is convenient to get the key name and the key value with the solution assignment of the variable.

var map=NewMap(); map.Set(' First ',' Hello '); map.Set(' Second ', ' World ');  for (let [key, value] of map) {console.  Log(key + "is" + value);} //First is Hello//second            are world 

Note: Map.first = ' Hello ';
Map.second = ' world ';
Such an assignment does not have a iterator interface, so it is not possible to traverse the map and fetch the Key/value value using the above method.

 

ES Learning Notes

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.