This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let obj = {id: 1, name: "John Doe", age: 25}; | |
/** | |
* Object.freeze() | |
* | |
* In freeze object, addition, updation and delete operation cannot be done except read | |
* | |
*/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* Promise.race will first settled either fulfilled or rejected from the iterable object | |
* | |
* Promise.any find the first fulfilled without concern of reject promise from the iterable object. | |
* If all are rejected promise then it will result an AggregateError. | |
* | |
*/ | |
// On passing first resolve and second reject promise |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
db.collection_name.insert([ | |
{_id: 1, name: "John Doe", age: 25}, | |
{_id: 2, name: "Foo Bar", age: 35}, | |
{_id: 3, name: "Hello World"} | |
]); | |
// create sparse index | |
db.scores.createIndex( { age: 1 } , { sparse: true } ); | |
// count the sparse Indexes Field will output 2 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const {performance} = require('perf_hooks'); | |
// using hrtime API | |
const hrBefore = process.hrtime(); | |
setTimeout(function () { | |
const hrAfter = process.hrtime(hrBefore); | |
console.log(`Using hrtime ${hrAfter[0] * 1e3 + hrAfter[1] / 1e6}ms`); |