const Moment = require('moment')
const array = [{date:"2018-05-11"},{date:"2018-05-12"},{date:"2018-05-10"}]
const sortedArray = array.sort((a,b) => new Moment(a.date).format('YYYYMMDD') - new Moment(b.date).format('YYYYMMDD'))
console.log(sortedArray)
This file contains hidden or 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 func1 = () => { | |
| setImmediate(() => console.log("setImmediate1")); | |
| process.nextTick(() => console.log("process.nextTick1")); | |
| setTimeout(() => console.log("setTimeout1"), 0); | |
| } | |
| const func2 = () => { | |
| setImmediate(() => console.log("setImmediate2")); | |
| process.nextTick(() => console.log("process.nextTick2")); | |
| setTimeout(() => console.log("setTimeout2"), 0); | |
| } |
This file contains hidden or 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
| setImmediate(() => console.log(“setImmediate”)); | |
| process.nextTick(() => console.log(“process.nextTick”)); | |
| setTimeout(() => console.log(“setTimeout”), 0); |
This file contains hidden or 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 fs = require('fs'), | |
| path = require('path'), | |
| filePath = path.join(__dirname, 'test.js'); | |
| setTimeout(()=> console.log("setTimeout"), 0); | |
| Promise.resolve().then(() => console.log("promise")) | |
| fs.readFile('filePath', function() { | |
| console.log('readFile'); | |
| }); |
This file contains hidden or 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
| setTimeout(() => console.log("1"), 0); | |
| Promise.resolve().then(() => console.log("2")); | |
| console.log("3"); |
This file contains hidden or 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 start = Date.now(); | |
| setTimeout(() => console.log(Date.now()-start), 1000); | |
| for(let i=0;i<1000;i++); |
This file contains hidden or 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.resolve().then(() => console.log("promise resolved")); | |
| process.nextTick(() => console.log("process.nextTick")); |
This file contains hidden or 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
| console.log("1"); | |
| setTimeout(() => console.log("2"),0); | |
| var promise = new Promise(function(resolve, reject) { | |
| resolve(); | |
| }); | |
| promise.then(function(resolve) { | |
| console.log('3'); | |
| }) | |
| .then(function(resolve) { | |
| console.log('4'); |
This file contains hidden or 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
| 1. Somewhere on your machine clone the project. | |
| ``` | |
| > git clone https://github.com/facebook/react-devtools.git | |
| > cd react-devtools | |
| ``` | |
| 2. Switch to the v3 branch | |
| ``` | |
| > git checkout v3 | |
| ``` |
NewerOlder