Logical functions for JavaScript