Javascript Shorthand to cast the value into the array…
const castArray = value => Array.isArray(value) ? value : [value];
// Examples
castArray(1); // [1]
castArray([1, 2, 3]); // [1, 2, 3]
const castArray = value => Array.isArray(value) ? value : [value];
// Examples
castArray(1); // [1]
castArray([1, 2, 3]); // [1, 2, 3]
Hi there, do you have a question?
This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.