Given two arrays, how to to pass a combination of both to a function, preferably with inline syntax?
var current = [1.01, 3.01, 2.42, 4.31];
var preview = [0.89, 3.15];
/*
* pass both combined to a function, this is fictional syntax.
* display(current + preview);
*/
What I mean by inline syntax to create an temporary array which gets passed. I don't want one of my arrays to be modified.
您可以使用concat
来创建一个包含两个值的新数组:
display(current.concat(preview));
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.