简体   繁体   中英

Node.js not show error

Why when property in object not exist, node.js just die and not show any warning or error? How catch this error?

var element={};
var data=element.data.split('\n');

use try catch

try {
    var element = {};
    var data = element.data.split('\n');
} catch (e) {
    console.log(e);
}

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM