Mô-đun Node.js Util

❮ Mô-đun tích hợp


Thí dụ

Định dạng một chuỗi bằng cách sử dụng các đối số "Linus" và "6":

var util = require('util');
var txt = 'Congratulate %s on his %dth birthday!';
var result = util.format(txt, 'Linus', 6);

console.log(result);

Định nghĩa và Cách sử dụng

Mô-đun Util cung cấp quyền truy cập vào một số chức năng tiện ích.


Cú pháp

Cú pháp để đưa mô-đun Util vào ứng dụng của bạn:

var util = require('util');

Thuộc tính và phương thức Util

Method Description
debuglog() Writes debug messages to the error object
deprecate() Marks the specified function as deprecated
format() Formats the specified string, using the specified arguments
inherits() Inherits methods from one function into another
inspect() Inspects the specified object and returns the object as a string

❮ Mô-đun tích hợp