<<

foo.constructor === Object

is what cljs.core/object? does.

>>

Hi David,

That wouldn't work for Date, RegExp, Number or String objects since it
would have to be be: a.constructor === Date,  a.constructor === RegExp,
a.constructor === Number and a.constructor === String, respectively.

For example, if you had 'var date = new Date()' then   'date.constructor
=== Date' would evaluate to true but 'date.constructor === Object' would be
evaluate to false. Same with RegExp objects. These are common.

Number and String objects created via the 'new' keyword are not that
common, or at least I've never used them e.g. var string = new String("abc")

I know this is outside the use case for cljs.core/object?, but just wanted
to clarify for others who may be tempted to use it for recognizing object
types in general



On Wed, Aug 5, 2015 at 9:04 AM, David Nolen <[email protected]> wrote:

> Ah heh yes, I couldn't remember.
>
> foo.constructor === Object
>
> is what cljs.core/object? does.
>
> David
>
> On Wed, Aug 5, 2015 at 12:00 PM, Marc Fawzi <[email protected]> wrote:
>
>> A JS question for the CLJS master :)
>>
>> I think by 'foo.constructor.prototype === Object'
>>
>> you meant either this: foo.constructor.prototype === Object.prototype
>>
>> or this: a.constructor === Object
>>
>> but not 'foo.constructor.prototype === Object'
>>
>>
>>
>>
>>
>>
>>
>>
>> On Wed, Aug 5, 2015 at 7:51 AM, David Nolen <[email protected]>
>> wrote:
>>
>>> Er, that test would have be `foo.constructor.prototype === Object`.
>>>
>>> David
>>>
>>> On Wed, Aug 5, 2015 at 10:50 AM, David Nolen <[email protected]>
>>> wrote:
>>>
>>>> There is no simple test for plain objects, `typeof x` will return
>>>> `"object"` for many things. only `foo.constructor === Object` is going to
>>>> work. This is not as fast as it would seem.
>>>>
>>>> We're not going to add any more cases to `get`.
>>>>
>>>> I've said all I'm going to say about this matter :)
>>>>
>>>> David
>>>>
>>>> On Wed, Aug 5, 2015 at 10:43 AM, Peter Taoussanis <
>>>> [email protected]> wrote:
>>>>
>>>>> > Yes performance. We not adding any more cases to `get`.
>>>>>
>>>>> `get`'s implemented with `cond` - adding an object case after other
>>>>> conditions (before `:else nil`) wouldn't affect performance in any real
>>>>> way, would it?
>>>>>
>>>>> Is object property access not a pretty common occurrence?
>>>>>
>>>>> --
>>>>> Note that posts from new members are moderated - please be patient
>>>>> with your first post.
>>>>> ---
>>>>> You received this message because you are subscribed to the Google
>>>>> Groups "ClojureScript" group.
>>>>> To unsubscribe from this group and stop receiving emails from it, send
>>>>> an email to [email protected].
>>>>> To post to this group, send email to [email protected].
>>>>> Visit this group at http://groups.google.com/group/clojurescript.
>>>>>
>>>>
>>>>
>>> --
>>> Note that posts from new members are moderated - please be patient with
>>> your first post.
>>> ---
>>> You received this message because you are subscribed to the Google
>>> Groups "ClojureScript" group.
>>> To unsubscribe from this group and stop receiving emails from it, send
>>> an email to [email protected].
>>> To post to this group, send email to [email protected].
>>> Visit this group at http://groups.google.com/group/clojurescript.
>>>
>>
>> --
>> Note that posts from new members are moderated - please be patient with
>> your first post.
>> ---
>> You received this message because you are subscribed to the Google Groups
>> "ClojureScript" group.
>> To unsubscribe from this group and stop receiving emails from it, send an
>> email to [email protected].
>> To post to this group, send email to [email protected].
>> Visit this group at http://groups.google.com/group/clojurescript.
>>
>
> --
> Note that posts from new members are moderated - please be patient with
> your first post.
> ---
> You received this message because you are subscribed to the Google Groups
> "ClojureScript" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> To post to this group, send email to [email protected].
> Visit this group at http://groups.google.com/group/clojurescript.
>

-- 
Note that posts from new members are moderated - please be patient with your 
first post.
--- 
You received this message because you are subscribed to the Google Groups 
"ClojureScript" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/clojurescript.

Reply via email to