Node.js – process.throwDeprecation() 方法
此方法指示 **--throw-deprecation** 標誌值在當前 Node.js 專案中設定為 true 或 false。
process.throwDeprecation() 方法是可變的,因此棄用警告導致的錯誤可能會在執行時被更改。
語法
process.throwDeprecation( )
示例1
建立一個名為"throwDeprecation.js"的檔案,並複製以下程式碼。建立檔案後,使用"node throwDeprecation.js"命令執行此程式碼,如下例所示
// process.throwDeprecation() Demo Example
// Importing the process module
const process = require('process');
// Printing the --throw-Deprecation default value
console.log(process.throwDeprecation);輸出 1
undefined
輸出 2
true
示例 2
我們來看另一個示例
// process.throwDeprecation() Demo Example
// Importing the process module
const process = require('process');
// Initializing the throwDeprecation flag
process.throwDeprecation = false;
// Printing throwDeprecation
console.log(process.throwDeprecation);
// Initializing the throwDeprecation flag
process.throwDeprecation = true;
// Printing throwDeprecation
console.log(process.throwDeprecation);輸出 1
false true
輸出 2
true true
廣告
資料結構
網路
RDBMS
作業系統
Java
iOS
HTML
CSS
Android
Python
C 程式設計
C++
C#
MongoDB
MySQL
Javascript
PHP