// Importing util library const util = require('util'); const { inspect } = require('util'); // Importing http module var http = require('http'); // Inspecting http module console.log("1.>", util.inspect(http, { showHidden: false, depth: 0, showProxy: false })); // Inspecting console module console.log("2.>", util.inspect( console, showHidden = false, depth = 0, showProxy = true)); // Creating array filled with default value 1 const inspectArray = Array(108).fill(1); // Prints the truncated array console.log("3.>", inspectArray); util.inspect.defaultOptions.maxArrayLength = null; // Prints the full array console.log("4.>", inspectArray); const object = { amit: [1, 2, [[ 'alfa_romeo, spp___, sahai_harshit ' + 'Annapurna, chai paratha.', 'chota', 'bong']], 55], vikas: new Map([ ['alfa', 1], ['romeo', 'data']]) }; // Returns the compact view output. console.log("5.>", util.inspect(object, { compact: true, depth: 5, breakLength: 80 })); // Returns the output more reader friendly. console.log("6.>", util.inspect(object, { compact: false, depth: 5, breakLength: 80 })); const object1 = { alfa: 10 }; const object2 = { beta: 20 }; // Creating weakSet const inspectingWeakset = new WeakSet([object1, object2]); console.log("7.>", inspect( inspectingWeakset, { showHidden: true })); // Output { { alfa: 10 }, { beta: 20 } } object2[util.inspect.custom] = (depth) => { return { alfaa: 'romeo' }; }; console.log("8.>", util.inspect(object2)); console.log(util.inspect(http, true, 1)); console.log(util.inspect(http, true, 3)); // Prints: "{ alfaa: 'romeo' }" console.log(util.inspect(console, true)); console.log(util.inspect({a:1, b:"b"}, false,2,true));
Write, Run & Share NodeJS code online using OneCompiler's NodeJS online compiler for free. It's one of the robust, feature-rich online compilers for NodeJS language,running on the latest LTS version NodeJS 16.14.2. Getting started with the OneCompiler's NodeJS editor is easy and fast. The editor shows sample boilerplate code when you choose language as NodeJS and start coding. You can provide the dependencies in package.json
.
Node.js is a free and open-source server environment. Node.js is very popular in recent times and a large number of companies like Microsoft, Paypal, Uber, Yahoo, General Electric and many others are using Node.js.
Google chrome's javascript engine V8
and is pretty fast.Asynchronous
, event-driven
and works on single-thread model
thus eliminating the dis-advantages of multi-thread model.Express is one of the most popular web application framework in the NodeJS echosystem.
let moment = require('moment');
console.log(moment().format('MMMM Do YYYY, h:mm:ss a'));
const _ = require("lodash");
let colors = ['blue', 'green', 'yellow', 'red'];
let firstElement = _.first(colors);
let lastElement = _.last(colors);
console.log(`First element: ${firstElement}`);
console.log(`Last element: ${lastElement}`);
Following are the libraries supported by OneCompiler's NodeJS compiler.