I was wondering if it was possible to pass an instance method into the Array.prototype.map function.
for example, I basically want this functionality without having to make a separate function
function Node(n) {
this.val = n;
}
Node.prototype.isBig = function() {
return this.val > 5;
}
var myArray = [
new Node(1), new Node(2), new Node(3),
new Node(7), new Node(8), new Node(9)
];
console.log(myArray);
var result = myArray.map(function(node) {
return node.isBig();
});
console.log(result);
in java I would be able to do .map(Node::isBig). Can I do something to change the map parameter so that I don't have to create a function?
I am also open to solutions with lodash if you cannot do it with vanilla js.