Node.js मॉड्यूल का उपयोग करें
उदाहरण
"लिनुस" और "6" तर्कों का उपयोग करके एक स्ट्रिंग को प्रारूपित करें:
var util = require('util');
var txt = 'Congratulate %s on his %dth
birthday!';
var result = util.format(txt, 'Linus', 6);
console.log(result);
परिभाषा और उपयोग
यूटिल मॉड्यूल कुछ उपयोगिता कार्यों तक पहुंच प्रदान करता है।
वाक्य - विन्यास
आपके एप्लिकेशन में यूटिल मॉड्यूल को शामिल करने के लिए सिंटैक्स:
var util = require('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 |