What is the easiest way to test for class membership in coffeescript?

后端 未结 2 559
情歌与酒
情歌与酒 2021-02-02 13:21

I\'m looking for an equivalent of Ruby\'s \"blah\".is_a?(String) of Objective-C\'s [@\"blah\" isKindOfClass:[NSString class]]

2条回答
  •  抹茶落季
    2021-02-02 14:03

    It feels wrong for me to create an instance of a class. You never know, what parameters the constructor might expect.

    So what I came up with is this:

    class A
    class B extends A
    
    console.log B.__super__ is A.prototype# => true
    

提交回复
热议问题