js: write 'contains' and 'empty' helper methods