- Clear feature ownership
- Module usage predictibility (refactoring, maintainence, you know what's shared, what's not, prevents accidental regressions, avoids huge directories of not-actually-reusable modules, etc)
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 numberArray = [1, 2, 3, 4, 5] | |
| let stringArray = ['1', '2', '3', '4', '5'] | |
| stringArray = numberArray.map(String); | |
| numberArray = stringArray.map(Number); | |
| console.log('numberArray', numberArray) | |
| console.log('stringArray', stringArray) |
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 dirty = [ 1, null, false, 2, 3, null, 5, 0, 10, ''] | |
| const clean = dirty.filter(Boolean); | |
| console.log(clean) |
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 varA = 'A' | |
| let varB = 'B' | |
| function change() { [varA, varB] = [varB, varA] } | |
| change() | |
| console.log('varA', varA) | |
| console.log('varB', varB) |
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 objectOne = { | |
| id: 1, | |
| name: 'one' | |
| } | |
| let objectTwo = { | |
| descr: 'object number two' | |
| } | |
| const mergedObject = { ...objectOne, ...objectTwo }; |
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 myProperty = { | |
| id: 1, | |
| name: 'one' | |
| } | |
| const myObject = { ...myProperty && { propName: myProperty } }; | |
| console.log('myObject', myObject) |
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 myArray = [1, 1, 1, 2, 3, 2, 4, 5, 4] | |
| const deDupe = [...new Set(myArray)]; | |
| console.log('original', myArray) | |
| console.log('de-dupped', deDupe) |
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
| <template> | |
| <div id="app"> | |
| <p> | |
| Pending: {{ $store.state.getInfoPending }} | |
| </p> | |
| <p> | |
| {{ $store.state.getInfoData }} | |
| </p> | |
| </div> | |
| </template> |
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
| var roleBuilder = { | |
| /** @param {Creep} creep **/ | |
| run: function(creep) { | |
| if(creep.memory.building && creep.carry.energy == 0) { | |
| creep.memory.building = false; | |
| creep.say('🔄 harvest'); | |
| } | |
| if(!creep.memory.building && creep.carry.energy == creep.carryCapacity) { |
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
| var roleUpgrader = { | |
| /** @param {Creep} creep **/ | |
| run: function(creep) { | |
| if(creep.carry.energy == 0) { | |
| var sources = creep.room.find(FIND_SOURCES); | |
| if(creep.harvest(sources[0]) == ERR_NOT_IN_RANGE) { | |
| creep.moveTo(sources[0]); | |
| } | |
| } |
NewerOlder