繁体   English   中英

如何在 ES6 中控制台记录以下对象?

[英]How do I console.log the following objects in ES6?

如何使用 ES6 方法控制台记录结果 ["cat", "mouse"]?

这是我当前的代码,当我 console.log(collectionAnimals) 时它不起作用

 function collectAnimals(...animalList) { return animalList; } collectAnimals("cat", "mouse"); console.log(collectAnimals)

您需要将值存储在变量中..

在这一行中:

collectAnimals("cat", "mouse");

您没有将其存储在任何地方,因此一旦该行执行从中形成或创建的数据,就会被删除

因此,将其存储在这样的变量中

let x = collectAnimals("cat", "mouse");
console.log(x);

然后打印“x”

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM