比方說,我有一個精縮JavaScript文件這一功能:使用的toString時如何格式化函數體()
function fn(){console.log('Lorem');console.log('Ipsum');}
我想獲得一個漂亮的印刷,縮進版本打電話時:
console.log(fn.toString());
預期輸出:
function fn() {
console.log('Lorem');
console.log('Ipsum');
}
相反的:
function fn(){console.log('Lorem');console.log('Ipsum');}
無論如何要做到這一點?