Last active
February 15, 2017 20:45
-
-
Save failpunk/41a047dd371f4fec433f1ac63ab63c17 to your computer and use it in GitHub Desktop.
Lodash to Javascript 2016+
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
// https://bitbucket.org/repomode/bartleby-frontend/pull-requests/6/merging-dev-to-master-for-push-to-staging/diff#Lapp/routes/category/category.model.jsT144 | |
// Lodash assign (just use Object.assign). | |
// Lodash uses Object.assign behind the scenes anyway. | |
Object.assign(obj, {}, {}); | |
// https://bitbucket.org/repomode/bartleby-frontend/src/3ee2cc7aca1a49ab3baa311173780da07b5a6d9f/app/routes/category/category.model.js?fileviewer=file-view-default#category.model.js-38 | |
// Lodash.get (just use the or operator) | |
let temp = {a: 'a',b: 'b',c: 'c'}; | |
temp.a || ‘z’; | |
// If you want to use a Lodash method, consider abstracting it behind a method. | |
// This allows it to more easily be swapped out later and keeps things DRY. | |
function getKey(object, key, default) { | |
return Lodash.get(object, key, default) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment