javascript check if object implements interface