
- Node.js 教程
- Node.js - 首頁
- Node.js - 簡介
- Node.js - 環境搭建
- Node.js - 第一個應用
- Node.js - REPL 終端
- Node.js - 命令列選項
- Node.js - 包管理器 (NPM)
- Node.js - 回撥函式概念
- Node.js - 上傳檔案
- Node.js - 傳送郵件
- Node.js - 事件
- Node.js - 事件迴圈
- Node.js - 事件發射器
- Node.js - 偵錯程式
- Node.js - 全域性物件
- Node.js - 控制檯
- Node.js - 程序
- Node.js - 應用程式擴充套件
- Node.js - 打包
- Node.js - Express 框架
- Node.js - RESTful API
- Node.js - 緩衝區
- Node.js - 流
- Node.js - 檔案系統
- Node.js MySQL
- Node.js - MySQL 入門
- Node.js - MySQL 建立資料庫
- Node.js - MySQL 建立表
- Node.js - MySQL 插入資料
- Node.js - MySQL 查詢資料
- Node.js - MySQL 條件查詢
- Node.js - MySQL 排序
- Node.js - MySQL 刪除資料
- Node.js - MySQL 更新資料
- Node.js - MySQL 連線查詢
- Node.js MongoDB
- Node.js - MongoDB 入門
- Node.js - MongoDB 建立資料庫
- Node.js - MongoDB 建立集合
- Node.js - MongoDB 插入資料
- Node.js - MongoDB 查詢資料
- Node.js - MongoDB 查詢
- Node.js - MongoDB 排序
- Node.js - MongoDB 刪除資料
- Node.js - MongoDB 更新資料
- Node.js - MongoDB 限定結果集
- Node.js - MongoDB 連線查詢
- Node.js 模組
- Node.js - 模組
- Node.js - 內建模組
- Node.js - 實用程式模組
- Node.js - Web 模組
- Node.js 有用資源
- Node.js - 快速指南
- Node.js - 有用資源
- Node.js - 討論
Node.js - os.EOL 屬性
Node.js 的 os.EOL 屬性代表作業系統特定的行結束標記。它用於獲取由作業系統指定的行結束標記或字元。
如果嘗試在 Windows 作業系統上執行 os.EOL,則會將“\r\n”返回到輸出。否則,如果在 POSIX 作業系統上執行它,則會將“\n”返回到輸出。
語法
以下是 Node.js os.EOL 屬性的語法:
os.EOL
引數
os.EOL 不接受任何引數。
返回值
它返回由作業系統指定的 EOL(行結束標記)。
現在讓我們深入瞭解 Node.js 中 os.EOL 在不同場景下的示例。
示例
在以下示例中,我們嘗試使用 JSON.stringify 列印 os.EOL 屬性。如果嘗試不進行字串化就列印它,它將作為行結束符列印。
const os = require('os'); const { EOL } = os; console.log(JSON.stringify((os.EOL)));
輸出
"\n"
注意 - 要獲得準確的結果,最好在本地執行上述程式碼。
如果我們編譯並執行上述程式,os.EOL 將按如下所示的圖中列印。
"\r\n"
示例
在下面的示例中,我們正在列印 os.EOL 以及一個字串。因此,它的行為類似於“換行”。
const os = require('os'); const { EOL } = os; console.log('Welcome to Tutorialspoint' + os.EOL + 'Hope you have a great learning here!');
輸出
正如我們在下面的輸出圖中看到的,os.EOL 之前的字串被打印出來,然後 os.EOL 列印行結束符,因此 os.EOL 之後的字串將在下一行列印。
Welcome to Tutorialspoint Hope you have a great learning here!
示例
在以下示例中,我們正在列印 os.EOL 字元以及一組字串。
const os = require('os'); const { EOL } = os; console.log('The calender months are' + os.EOL + "JANUARY" + os.EOL + "FEBRAURY" + os.EOL + "MARCH" + os.EOL + "APRIL" + os.EOL + "MAY" + os.EOL + "JUNE" + os.EOL + "JULY" + os.EOL + "AUGUST" + os.EOL + "SEPTEMBER" + os.EOL + "OCTOBER" + os.EOL + "NOVEMBER" + os.EOL + "DECEMBER");
輸出
如果我們編譯並執行上述程式,將列印一組字串以及 os.EOL。os.EOL 列印行結束符,因此每個 os.EOL 之後的下一個字串將在下一行列印。
The calender months are JANUARY FEBRAURY MARCHAPRIL MAY JUNE JULY AUGUST SEPTEMBER OCTOBER NOVEMBER DECEMBER
nodejs_os_module.htm
廣告