473,471 Members | 1,967 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

instanceof operator

Hi,

How widely supported is the instanceof operator? Is there an alternative
to seeing if an object is an instance of a constructor?

Many thanks

Regards

Aaron
Jun 27 '08 #1
3 2122
whitelined wrote:
How widely supported is the instanceof operator?
See
http://developer.mozilla.org/en/docs...nceof_Operator
it has been implemented first in JavaScript 1.4 so for Mozilla browser
anything from Netscape 6 and later, Mozilla 1.0, Firefox 1.0 supports it
as those browser have JavaScript 1.5 or later.
For MS JScript see
http://msdn.microsoft.com/en-us/libr...6z(VS.85).aspx, instanceof
is supported since JScript 5 which appeared with IE 5 I think.

--

Martin Honnen
http://JavaScript.FAQTs.com/
Jun 27 '08 #2
On May 30, 11:35*am, whitelined wrote:
Hi,

How widely supported is the instanceof operator?
It was introduced into ECMAScript in the 3rd edition of the
specification (end of 1999), and is now very widely supported.
Is there an alternative
to seeing if an object is an instance of a constructor?
There is no sense in which javascript objects are "an instance of a
constructor". The nearest you would get to that is saying that an
object was created using a constructor, and the - instanceof -
operator does not tell you that. Javascript's - instanceof - operator
determines whether the [[Prototype]] of an object is the same object
as the object currently assigned to the - prototype - property of a
function. As the latter is runtime assignable a false result form an -
instanceof - operation does not necessarily mean that the object was
not created using the function as a constructor. And as the same
object may be assigned to the - prototype - properties of many
functions a true result from an - instanceof - operation does not
necessarily mean that the object was constructed using the function as
a constructor.

The result is that if what you are writing is so chaotic by design
that you need to determine the type of an object at runtime the -
instanceof - operation is not going to be of much help in doing so.

Jun 27 '08 #3
whitelined wrote:
How widely supported is the instanceof operator? [...]
See http://PointedEars.de/es-matrix for updated version information about
this and other language features.
Many thanks
You are welcome.
PointedEars
--
Anyone who slaps a 'this page is best viewed with Browser X' label on
a Web page appears to be yearning for the bad old days, before the Web,
when you had very little chance of reading a document written on another
computer, another word processor, or another network. -- Tim Berners-Lee
Jun 27 '08 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: John MacIntyre | last post by:
Hi, I have a page with a series of child pages loaded into an iframe. When I move from page to page, I store an object containing the child's control data in a variable on the main page, then...
7
by: chirs | last post by:
Hi, These 2 lines caused an error in IE5. The error is "Function expected". Why? var d=new Date(); document.write(d instanceof Object + "<br>"); Thanks.
5
by: Beginner | last post by:
What is the c++ version of instanceof()? Thank-you
5
by: rua17 | last post by:
Can anyone tell me what's the command in c# that is equivalent to the instanceOf in java? thanks
4
by: Sean Inglis | last post by:
Well bizarre to me, anyway. I've distilled it down to two small files: testtop.htm =============================== <html> <head> <script language="Javascript">
2
by: System Administrator | last post by:
Hi: Can someone explain why BOTH of the following are true ? Function instanceof Object //true Object instanceof Function //true (Either one or the other should be true, not both,...
2
by: System Administrator | last post by:
function a() { } typeof a //returns 'function' a instanceof a //returns false typeof Object //returns 'function' Object instanceof Object //returns ...
15
by: shana07 | last post by:
Can I have many instanceof code for one 'if' ? for example..... if(checkMe instanceof AInstruction instanceof LocVariableInst) What I am trying to say is, these instanceof are refer to these...
30
by: kj | last post by:
My book (Flanagan's JavaScript: The Definitive Guide, 5th ed.) implies on page 111 that the following two constructs are equivalent: ( x.constructor == Foo ) and ( x instanceof Foo ) The...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.