Last active
October 3, 2017 08:56
-
-
Save Gpzim98/5bf6b0946b30673bda44670470585ec3 to your computer and use it in GitHub Desktop.
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
# 1 - Promisses | |
p.then(onFulfilled[, onRejected]); | |
p.then(function(value) { | |
// fulfillment | |
}, function(reason) { | |
// rejection | |
}); | |
# 2 - Find an object in a array | |
let obj = arr.find((o, i) => { | |
if (o.name === 'string 1') return true; | |
}); | |
# 3 - Replacing object in a array | |
let arr = [ | |
{ name:"string 1", value:"this", other: "that" }, | |
{ name:"string 2", value:"this", other: "that" } | |
]; | |
let obj = arr.find((o, i) => { | |
if (o.name === 'string 1') { | |
arr[i] = { name: 'new string', value: 'this', other: 'that' }; | |
return true; // stop searching | |
} | |
}); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment