Created
April 10, 2020 07:18
-
-
Save DoubleMarv/767b976be3cc0d39cf262010b006cd64 to your computer and use it in GitHub Desktop.
Underscorejs where and map
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
<!DOCTYPE html> | |
<html lang="en"> | |
<head> | |
<meta charset="utf-8"> | |
<title>Underscore basic</title> | |
<script src="https://cdnjs.cloudflare.com/ajax/libs/underscore.js/1.9.1/underscore-min.js"></script> | |
</head> | |
<body> | |
<div id="demo"></div> | |
<script> | |
var blarray = [ | |
{ | |
name: 'jane', | |
legs: 'long' | |
}, | |
{ | |
name: 'mary', | |
legs: 'short' | |
}, | |
{ | |
name: 'davina', | |
legs: 'blue' | |
}, | |
] | |
var doita = _.where(blarray, {legs: "blue"}); | |
var doit = _.map(blarray, function(key){ return key.name.toUpperCase(); }); | |
console.log(doita); | |
console.log(doit); | |
</script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment