Skip to content

Instantly share code, notes, and snippets.

Created Oct 16, 2014
What would you like to do?
Helpful utility to get array-items based on indexOf.
function take (item, array, context) {
  return array[(context || array).indexOf(item)];

var nodes = document.getElementsByTagName('div');
var array = [];
var item = array[2];

var tooked = take(item, array); // => <div>2</div>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment