Why (new RegExp) type is function not object 
December 8th, 2007, 12:35 AM
| | | Why (new RegExp) type is function not object
typeof new RegExp
----------------------------------------------------
Why (new RegExp) type is function not object
very thanks for you consulation | 
December 8th, 2007, 03:05 AM
| | | Re: Why (new RegExp) type is function not object
EME wrote: Quote:
typeof new RegExp
----------------------------------------------------
Why (new RegExp) type is function not object
>
very thanks for you consulation
| A function is an object. The ECMA spec section 11.4.3 says that the
typeof operator returns 'function' for objects that are functions[1],
and 'object' for objects that aren't functions.
Note that IE doesn't do that, it returns 'object' for functions.
1. It actually says "native and implements [[call]]", but it means
function. :-)
--
Rob
"We shall not cease from exploration, and the end of all our
exploring will be to arrive where we started and know the
place for the first time." -- T. S. Eliot | 
December 8th, 2007, 04:36 AM
| | | Re: Why (new RegExp) type is function not object
On 8 ΔΕΛ, 06:33, EME <megaupload.sh...@gmail.comwrote: Quote:
typeof new RegExp
----------------------------------------------------
Why (new RegExp) type is function not object
>
| Actually, only SpiderMonkey creates function, evaluating -new RegExp-
expression. It's more like extension of the engine since the
calculated object has no properties length and prototype. | 
December 8th, 2007, 04:36 AM
| | | Re: Why (new RegExp) type is function not object
On 8 ΔΕΛ, 09:03, RobG <rg...@iinet.net.auwrote: Quote:
>
Note that IE doesn't do that, it returns 'object' for functions.
>
| I hope you meant: "it returns 'object' for host functions". | 
December 8th, 2007, 07:05 AM
| | | Re: Why (new RegExp) type is function not object
for furthur more,i have detail test below:
typeof new RegExp //result 'function' in Firefox, 'object' in IE6
new RegExp instanceof Function //result false in Firefox
(new RegExp)() in Firefox is same as (new RegExp).exec() | 
December 8th, 2007, 12:15 PM
| | | Re: Why (new RegExp) type is function not object
On Dec 8, 12:30 am, AKS <aksus...@yandex.ruwrote: Quote:
On 8 ΔΕΛ, 09:03, RobG <rg...@iinet.net.auwrote:
>
>
> Quote: |
Note that IE doesn't do that, it returns 'object' for functions.
| >
I hope you meant: "it returns 'object' for host functions".
| I would think so. | 
December 8th, 2007, 01:05 PM
| | | Re: Why (new RegExp) type is function not object
David Mark wrote: Quote:
On Dec 8, 2:55 am, EME <megaupload.sh...@gmail.comwrote: Quote: |
>new RegExp instanceof Function //result false in Firefox
| >
It isn't an instance of Function (it is an instance of RegExp.)
| It isn't an instance of anything, as that would imply class-based inheritance.
PointedEars
--
realism: HTML 4.01 Strict
evangelism: XHTML 1.0 Strict
madness: XHTML 1.1 as application/xhtml+xml
-- Bjoern Hoehrmann | 
December 8th, 2007, 01:05 PM
| | | Re: Why (new RegExp) type is function not object
On Dec 8, 8:57 am, Thomas 'PointedEars' Lahn <PointedE...@web.de>
wrote: Quote:
David Mark wrote: Quote:
On Dec 8, 2:55 am, EME <megaupload.sh...@gmail.comwrote: Quote: |
new RegExp instanceof Function //result false in Firefox
| | > Quote: |
It isn't an instance of Function (it is an instance of RegExp.)
| >
It isn't an instance of anything, as that would imply class-based inheritance.
>
| You are kidding right? The operator quoted above that sentence should
explain why I used that terminology. | 
December 8th, 2007, 01:25 PM
| | | Re: Why (new RegExp) type is function not object
David Mark wrote: Quote:
On Dec 8, 8:57 am, Thomas 'PointedEars' Lahn <PointedE...@web.de>
wrote: Quote:
>David Mark wrote: Quote:
>>On Dec 8, 2:55 am, EME <megaupload.sh...@gmail.comwrote:
>>>new RegExp instanceof Function //result false in Firefox
>>It isn't an instance of Function (it is an instance of RegExp.)
| >It isn't an instance of anything, as that would imply class-based inheritance.
| >
You are kidding right?
| I am not. Quote: |
The operator quoted above that sentence should explain why I used that terminology.
| The operator above was borrowed from Java, a programming language that
uses only class-based inheritance, to ease programming in JavaScript for
developers that a familiar with Java. However, `instanceof' is only a
name, not a hint regarding the underlying concept of the operation in
implementations of Edition 3 of the ECMAScript Language Specification.
It is therefore inappropriate to speak of objects as instances of their
constructors. http://developer.mozilla.org/en/docs...of_Differences
PointedEars
--
var bugRiddenCrashPronePieceOfJunk = (
navigator.userAgent.indexOf('MSIE 5') != -1
&& navigator.userAgent.indexOf('Mac') != -1
) // Plone, register_function.js:16 | 
December 8th, 2007, 02:15 PM
| | | Re: Why (new RegExp) type is function not object
On Dec 8, 9:15 am, Thomas 'PointedEars' Lahn <PointedE...@web.de>
wrote: Quote:
David Mark wrote: Quote:
On Dec 8, 8:57 am, Thomas 'PointedEars' Lahn <PointedE...@web.de>
wrote: Quote:
David Mark wrote:
>On Dec 8, 2:55 am, EME <megaupload.sh...@gmail.comwrote:
>>new RegExp instanceof Function //result false in Firefox
>It isn't an instance of Function (it is an instance of RegExp.)
It isn't an instance of anything, as that would imply class-based inheritance.
| | >>
I am not.
| That was a rhetorical question. I know you are serious about being
pedantic. Quote:
> Quote: |
The operator quoted above that sentence should explain why I used that terminology.
| >
The operator above was borrowed from Java, a programming language that
uses only class-based inheritance, to ease programming in JavaScript for
| No kidding. Quote:
developers that a familiar with Java. However, `instanceof' is only a
name, not a hint regarding the underlying concept of the operation in
| I wasn't taking a hint from it. Quote:
implementations of Edition 3 of the ECMAScript Language Specification.
It is therefore inappropriate to speak of objects as instances of their
constructors.
| Thanks for that. | 
December 8th, 2007, 02:15 PM
| | | Re: Why (new RegExp) type is function not object
On Dec 9, 1:06 am, David Mark <dmark.cins...@gmail.comwrote: Quote: |
On Dec 8, 9:15 am, Thomas 'PointedEars' Lahn <PointedE...@web.de>
| [...] Quote: Quote:
It is therefore inappropriate to speak of objects as instances of their
constructors.
| >
Thanks for that.
| Maybe the instanceof operator should be "constructedby"? :-)
--
Rob | 
December 8th, 2007, 08:55 PM
| | | Re: Why (new RegExp) type is function not object
On Sat, 8 Dec 2007 at 14:57:13, in comp.lang.javascript, Thomas
'PointedEars' Lahn wrote: Quote:
>David Mark wrote: Quote:
>On Dec 8, 2:55 am, EME <megaupload.sh...@gmail.comwrote: Quote: |
>>new RegExp instanceof Function //result false in Firefox
| >>
>It isn't an instance of Function (it is an instance of RegExp.)
| >
>It isn't an instance of anything, as that would imply class-based inheritance.
| Let's be really pedantic now. "An instance of RegExp" is just short for
"The object is a member of the class of all those objects that could
possibly be constructed by the function named RegExp".
Let's be differently pedantic now. Here is a quote from the ECMAScript
standard :
"RegExp instances inherit properties" ...
John
--
John Harris | 
December 12th, 2007, 04:55 PM
| | | Re: Why (new RegExp) type is function not object
RobG wrote: Quote:
On Dec 9, 1:06 am, David Mark wrote: Quote: |
>On Dec 8, 9:15 am, Thomas 'PointedEars' Lahn wrote:
| [...] Quote: Quote:
>>It is therefore inappropriate to speak of objects as
>>instances of their constructors.
| >>
>Thanks for that.
| >
Maybe the instanceof operator should be "constructedby"? :-)
| The - instanceof - operator makes an assertion about the runtime
relationship between the objects on an object's prototype chain and the
object/value referred to by the - prototype - property of a function at
the moment of the operation. Because the - prototype - properties of
functions can be assigned values at any time the results of -
instanceof - do not necessarily represent anything beyond the outcome of
the pertinent algorithms.
As usual, if the 'Class' concept has been employed in javascript code
design, not violated at runtime, and no attempt has been made to extend
that concept across possible multiple frames (so there is only a single
instance of each 'constructor') then javascript's - instanceof - can be
employed as if it was broadly analogous to Java's - instanceof -.
Unfortunately the coincidence of names tends to give people familiar
with Java the false impression that the two operators are more related
than they actually are (and then they whinge when they find out that the
relationship in javascript is much more specific and concrete than the
conceptual relationship that is implied in Java).
Richard. | | Thread Tools | Search this Thread | | | |
Posting Rules
| You may not post new threads You may not post replies You may not post attachments You may not edit your posts HTML code is Off | | | | | | What is Bytes?
We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights.
Get the best answers to your questions from over 220,989 network members.
|