Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/446.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript Es2015中的Curly Brakets_Javascript_Ecmascript 6_Brackets - Fatal编程技术网

Javascript Es2015中的Curly Brakets

Javascript Es2015中的Curly Brakets,javascript,ecmascript-6,brackets,Javascript,Ecmascript 6,Brackets,我在看一些推特,突然发现 语法把我弄糊涂了 const Font = ({ children }) => <Block... const Font=({children})=> 这是一种解构绑定模式。它表示参数children应绑定到传递给函数的对象的children属性的值 在ES2015环境中尝试以下操作: function x({ foo }) { console.log(foo); } x({ hello: "world", foo: "bar", well: "

我在看一些推特,突然发现

语法把我弄糊涂了

const Font = ({ children }) => 
 <Block...
const Font=({children})=>

这是一种解构绑定模式。它表示参数
children
应绑定到传递给函数的对象的
children
属性的值

在ES2015环境中尝试以下操作:

function x({ foo }) {
  console.log(foo);
}

x({ hello: "world", foo: "bar", well: "that's all"});
字符串“bar”将被记录到控制台,因为这是传递给函数的对象的“foo”属性的值


如果传递给函数的值是一个没有“children”属性的对象,或者如果它根本不是一个对象,那么参数将是
未定义的

似乎有一半新的快捷方式看起来像语法错误。。。