I'm looking for an equivalent of Ruby's "blah".is_a?(String)
of Objective-C's [@"blah" isKindOfClass:[NSString class]]
标签:
coffeescript
相关问题
- no difference between [..] and […] for array?
- Simple promise example with bluebird and coffeescr
- Grunt-browserify+mapify+coffeescript = module not
- How do I turn a String into a Readable Stream?
- CoffeeScript: How to return a array From class?
相关文章
- Most concise way to assign a value from a variable
- CoffeeScript String Comparison
- Change attribute using checkbox, AJAX, jQuery
- Parse error using Remotipart
- Combine and minify templates with CoffeeScript / C
- Can't require local CoffeeScript modules
- node.js http.request event flow - where did my END
- Rails 3.1 Ajax question
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:
Do you want to test whether an object is descended from a particular class? Then you want the
instanceof
keyword. (It's not something added by CoffeeScript; it's a part of JavaScript.) CoffeeScript classes are set up so that if you writethen the following is true:
Also, any object will return
true
forinstanceof Object
.If you want to test the specific class that an object is an instance of, use
.constructor
. For instance,or if you'd like to use a string,