473,769 Members | 5,449 Online
Bytes | Software Development & Data Engineering Community
+ 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 2140
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
13128
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 use that data to populate the controls when the child page is opened again. One of these objects contains an Array, and the page reloads fine using myArray, myArray, etc... But when I try perform some array methods on it (i.e.slice) ... it does...
7
4129
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
71022
by: Beginner | last post by:
What is the c++ version of instanceof()? Thank-you
5
61471
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
1917
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
2180
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, right ?)
2
1688
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 true Can anyone explain why when BOTH 'a' and 'Object' are functions,
15
3432
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 classes: public abstract class AInstruction extends Instruction & public abstract class LocVariableInst extends Instruction please advise me...thankssss
30
4702
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 author states that the instanceof operator computes its result
0
9590
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10223
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
7413
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6675
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5310
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5448
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3968
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3571
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2815
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.