Skip to content

JS 箭头函数单行运行多个函数及返回值

之前研究 js 压缩源码,看到过表达式之间用逗号分隔的写法,今天尝试了一下,让代码更加简洁,后续测试了一下返回值,作此记录。

js
const a = () => "aaa";
const b = () => "bbb";
const c = () => "ccc";

const test = () => (a(), b(), c());
console.log(test()); // => 'ccc'

返回值测试结果:返回最后一个函数的返回值

Release time: 4/28/2022, 9:52:00

Last updated:

⟣ Growing, with you. ⟢