var lib = {
bar: (a) => a,
baz: (b) => Math.pow(b, 4),
foo: (v) => 4 * v + 5,
}
try {
lib['foo'](Math.sin(45) + Math.cos(23))
} catch (e) {
console.log(e)
}
if ('foo' in lib) {
lib['foo'](Math.sin(45) + Math.cos(23))
} else {
console.log('error')
}
if (typeof lib['foo'] === 'function') {
lib['foo'](Math.sin(45) + Math.cos(23))
} else {
console.log('error')
}
if (Object.prototype.hasOwnProperty.call(lib, 'foo')) {
lib['foo'](Math.sin(45) + Math.cos(23))
} else {
console.log('error')
}