I have a code like this:
var methods = {
collapse: function(element) {
modify(element);
},
other_method: function() {
// ...
}
};
function modify(element)
{
console.log('collapse method');
}
Is it possible to minify collapse method to one line? So it should always call modify function.
Try this:
Because we have function declaration (not expression),
modifyis visible when you declare the objectmethods. The thing which is done here is just settingcollapseto be equal tomodify‘s reference.This is the same as: