The array corresponds to the sequence number one by one. This is a Correspondence of order

And objects are paired one by one according to their attribute names."/>

The array corresponds to the sequence number one by one. This is a Correspondence of order

And objects are paired one by one according to their attribute names.">

Home  >  Article  >  Web Front-end  >  Analytical structure in Es6

Analytical structure in Es6

PHP中文网
PHP中文网Original
2017-06-22 11:36:461363browse

<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title></title>
</head>
<body>
<h1>数组以序列号一一对应,这是一个有序的对应关系</h1>
<h1>而对象根据属性名一一对应,这是一个无序的对应关系</h1>
<script type="text/javascript">
// 首先有这么一个对象
const props = {
userName: &#39;button&#39;,
loading: false,
clicks: true,
disabled: &#39;disabled&#39;
}
//当我们想要取得其中的2个值:loading与clicked时:
// es5
var loading = props.loading;
var click = props.clicks;
console.log(loading)
console.log(clicks)
//es6
const { loading, clicks } = props;
// 给一个默认值,当props对象中找不到loading时,loading就等于该默认值
const { loading = false, clicks } = props;
// 比如
// section1 
import React, { Component } from &#39;react&#39;;
// section2
export { default } from &#39;./Button&#39;;
// section3
const { click, loading } = this.props;
const { isCheck } = this.state;
</script>
</body>
</html>


The above is the detailed content of Analytical structure in Es6. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn