Node.js 写到流 ES6 字符串String 方法 lastIndexOf() ES6 字符串String 方法 localeCompare() Node.js 写到流 var fs = require("fs"); var data = 'Simply Easy Learning'; // Create a writable stream var writerStream = fs.createWriteStream('output.txt'); // Write the data to stream with encoding to be utf8 writerStream.write(data,'UTF8'); // Mark the end of file writerStream.end(); // Handle stream events --> finish, and error writerStream.on('finish', function() { console.log("Write completed."); }); writerStream.on('error', function(err){ console.log(err.stack); }); console.log("Program Ended"); ES6 字符串String 方法 lastIndexOf() ES6 字符串String 方法 localeCompare()