使用解构从数组中仅提取第三项,并将其放入名为 suv
的变量中。
const vehicles = ['mustang', 'f-150', 'expedition'];
const [@(5)] = vehicles;
const vehicles = ['mustang', 'f-150', 'expedition'];
const [,,suv] = vehicles;
const vehicles = ['mustang', 'f-150', 'expedition'];
const [, ,suv] = vehicles;
const vehicles = ['mustang', 'f-150', 'expedition'];
const [, , suv] = vehicles;