
- 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 where 條件
- 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 - 討論
NodeJS - urlObject.slashes 屬性
NodeJS urlObject.slashes 屬性用於從 urlObject 獲取一個布林值。如果 URL 的協議部分的冒號 (:) 後需要兩個 ASCII 正斜槓 (//),則返回 true。否則,返回 false。
URL(統一資源定位符)是特定資源在各種 Web 伺服器中唯一的 Web 地址。
URL 中的協議指定了主機和 Web 瀏覽器之間如何傳輸資料。在 URL 中最常見的協議是 HTTP 和 HTTPS(安全),但還有其他網際網路協議,例如 FTP、UDP、POP、SMTP、DNS 等。
語法
以下是 NodeJS urlObject.slashes 屬性的語法:
urlObject.slashes
引數
此屬性不接受任何引數。
返回值
此屬性返回一個布林值。如果協議部分的冒號後需要兩個 ASCII 正斜槓字元 (//),則返回 true。否則,返回 false。
示例
在此示例中,我們檢查 URL 協議的冒號 (:) 後是否需要兩個 ASCII 正斜槓 (//)。
const url = require('url'); console.log(url.parse('ARP://site.com').slashes); console.log(url.parse('DHCP://site.com').slashes); console.log(url.parse('IMAP4://site.com').slashes); console.log(url.parse('SIP://site.com').slashes); console.log(url.parse('RTP://site.com').slashes); console.log(url.parse('RLP://site.com').slashes); console.log(url.parse('RAP://site.com').slashes); console.log(url.parse('L2TP://site.com').slashes); console.log(url.parse('PPTP://site.com').slashes); console.log(url.parse('SNMP://site.com').slashes); console.log(url.parse('TFTP://site.com').slashes);
輸出
以下是上述程式的輸出:
slashes 屬性返回 true,因為上述程式中的所有協議都需要 ASCII 正斜槓。
true true true true true true true true true true true
示例
在此示例中,我們使用其他一些協議來檢查它是否需要兩個 ASCII 正斜槓 (//) 字元。
console.log(url.parse('TCP://site.com').slashes); console.log(url.parse('IP://site.com').slashes); console.log(url.parse('UDP://site.com').slashes); console.log(url.parse('POP://site.com').slashes); console.log(url.parse('SMTP://site.com').slashes); console.log(url.parse('FTP://site.com').slashes); console.log(url.parse('HTTP://site.com').slashes); console.log(url.parse('HTTPS://site.com').slashes);
輸出
如下面的輸出所示,slashes 屬性返回 true,因為上述程式中的所有協議都需要 ASCII 正斜槓。
true true true true true true true true
nodejs_url_module.htm
廣告