473,385 Members | 1,465 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

typeof operator returns "unknown" instead of "undefined"


IE7 returns "unknown" instead of "undefined" when querying the type of
an unknown property of an object, for example

document.write(typeof window.missingproperty);

Has "unknown" been defined as a valid return value for the typeof
operator in a later version of ECMAScript or is this a JScript "feature"?

--
Klaus Johannes Rusch
Kl********@atmedia.net
http://www.atmedia.net/KlausRusch/
Jul 25 '06 #1
9 10678
Klaus Johannes Rusch wrote:
>
IE7 returns "unknown" instead of "undefined" when querying the type of
an unknown property of an object, for example

document.write(typeof window.missingproperty);

Has "unknown" been defined as a valid return value for the typeof
operator in a later version of ECMAScript or is this a JScript "feature"?
No to ECMAScript, yes to JScript - Microsoft added it to version 8,
along with 'date'.
--
Rob
Jul 26 '06 #2
JRS: In article <4i************@individual.net>, dated Wed, 26 Jul 2006
00:06:37 remote, seen in news:comp.lang.javascript, Klaus Johannes Rusch
<Kl********@atmedia.netposted :
>
IE7 returns "unknown" instead of "undefined" when querying the type of
an unknown property of an object, for example

document.write(typeof window.missingproperty);

Has "unknown" been defined as a valid return value for the typeof
operator in a later version of ECMAScript or is this a JScript "feature"?
It is bad to set follow-up without a note in the body; "FU set"
suffices. FU overridden.

My pages use such as
if (typeof(Inc1T)=='undefined') alert('File include1.js top fault, RSVP!')
with Inc1T=0 being defined at the top of file include1.js.

If this rather stupid change is confirmed, are there any suggestions for
alternatives to the above statement - preferably no longer, unlike
if ((typeof Inc1T).charAt(0)=='u') alert('File include1.js top fault, RSVP!')
?

FU set.

Read the newsgroup FAQ.
--
© John Stockton, Surrey, UK. ?@merlyn.demon.co.uk Turnpike v4.00 IE 4 ©
<URL:http://www.jibbering.com/faq/>? JL/RC: FAQ of news:comp.lang.javascript
<URL:http://www.merlyn.demon.co.uk/js-index.htmjscr maths, dates, sources.
<URL:http://www.merlyn.demon.co.uk/TP/BP/Delphi/jscr/&c, FAQ items, links.
Jul 26 '06 #3
Dr John Stockton said the following on 7/26/2006 8:42 AM:
JRS: In article <4i************@individual.net>, dated Wed, 26 Jul 2006
00:06:37 remote, seen in news:comp.lang.javascript, Klaus Johannes Rusch
<Kl********@atmedia.netposted :
>IE7 returns "unknown" instead of "undefined" when querying the type of
an unknown property of an object, for example

document.write(typeof window.missingproperty);

Has "unknown" been defined as a valid return value for the typeof
operator in a later version of ECMAScript or is this a JScript "feature"?

It is bad to set follow-up without a note in the body; "FU set"
suffices. FU overridden.
You are starting to act like TL. It is not bad set it without a note, it
is bad to set it at all on the original post. If the OP can figure out
where to set follow-up to then they should only post there as follow-up
is generally set to the most appropriate group.
My pages use such as
if (typeof(Inc1T)=='undefined') alert('File include1.js top fault, RSVP!')
with Inc1T=0 being defined at the top of file include1.js.
Why typeof? Why not just if(Inc1T). Depending on how Inc1T is defined
though.
If this rather stupid change is confirmed,
It is not a "stupid change", it actually makes sense.

are there any suggestions for
alternatives to the above statement - preferably no longer, unlike
if ((typeof Inc1T).charAt(0)=='u') alert('File include1.js top fault, RSVP!')
if (Inc1T)

But, it depends on how "unknown" gets translated to a Boolean. Does it
type convert to true or false?
Read the newsgroup FAQ.
For what reason in this post should they read the FAQ? Or is that your
new template?
--
Randy
comp.lang.javascript FAQ - http://jibbering.com/faq & newsgroup weekly
Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/
Answer:It destroys the order of the conversation
Jul 26 '06 #4
Randy Webb wrote:
Dr John Stockton wrote:
>Johannes Rusch wrote:
>>IE7 returns "unknown" instead of "undefined" when querying
the type of an unknown property of an object, for example

document.write(typeof window.missingproperty);
<snip>
>If this rather stupid change is confirmed,

It is not a "stupid change", it actually makes sense.
<snip>

If true, that all non-provided properties of the global/window object in
IE would report "unknown" when tested with the - typeof - operator, then
it would be a monumentally stupid modification for Microsoft to make to
in IE 7. It would probably kill 10% of browser scripts at a stroke.
Indeed it is such a stupid thing for Microsoft to have done that it is
extremely unlikely that they have done this, and instead it is the case
that the OP is misinterpreting whatever evidence he thinks he has for
this.

Defined properties of ActiveX objects, and some parts of the IE browser
object model, sometimes do return 'unknown' from typeof, so some poorly
selected property names may well produce the illusion of the effect
described. However, I have tested the substantial web application that I
am currently working on in IE 7 and encountered no significant issues
with it, and I cannot believe that in 60,000 lines of code there are no
typeof tests for non-'undefined' of global properties (even if none
spring to mind at the moment).

Richard.
Jul 26 '06 #5

Richard Cornford wrote:
Randy Webb wrote:
Dr John Stockton wrote:
Johannes Rusch wrote:
IE7 returns "unknown" instead of "undefined" when querying
the type of an unknown property of an object, for example

document.write(typeof window.missingproperty);
<snip>
If this rather stupid change is confirmed,
It is not a "stupid change", it actually makes sense.
<snip>

If true, that all non-provided properties of the global/window object in
IE would report "unknown" when tested with the - typeof - operator, then
it would be a monumentally stupid modification for Microsoft to make to
in IE 7. It would probably kill 10% of browser scripts at a stroke.
Indeed it is such a stupid thing for Microsoft to have done that it is
extremely unlikely that they have done this, and instead it is the case
that the OP is misinterpreting whatever evidence he thinks he has for
this.
Here's what I found in the JScript 8 Reference on MSDN:

<URL: http://msdn2.microsoft.com/en-us/library/d70y8358.aspx
>

Unfortunately, I can't find where they define the 'unkown' type, their
summary of data types is here (it doesn't mention unkown, undefined,
null...)

<URL: http://msdn2.microsoft.com/en-us/library/hhw1f6w5.aspx >

Defined properties of ActiveX objects, and some parts of the IE browser
object model, sometimes do return 'unknown' from typeof, so some poorly
selected property names may well produce the illusion of the effect
described. However, I have tested the substantial web application that I
am currently working on in IE 7 and encountered no significant issues
with it, and I cannot believe that in 60,000 lines of code there are no
typeof tests for non-'undefined' of global properties (even if none
spring to mind at the moment).
It would be nice to know from MS themselves how 'unknown' should
behave.
--
Rob

Jul 26 '06 #6
RobG wrote:
<snip>
It would be nice to know from MS themselves how 'unknown' should
behave.
the resulting value is Undefined, and typeof undefined is 'undefined'
so either Microsoft have seriously crippled compatibility with ECMA <=
3rd Ed. (so cross-browser compatibility in general) or the symptoms
have been miss-reported/identified. I may have time to try this myself
on IE 7 this afternoon.

Richard.

Jul 27 '06 #7


Richard Cornford wrote:

If true, that all non-provided properties of the global/window object in
IE would report "unknown" when tested with the - typeof - operator, then
it would be a monumentally stupid modification for Microsoft to make to
in IE 7. It would probably kill 10% of browser scripts at a stroke.
Indeed it is such a stupid thing for Microsoft to have done that it is
extremely unlikely that they have done this, and instead it is the case
that the OP is misinterpreting whatever evidence he thinks he has for
this.

Defined properties of ActiveX objects, and some parts of the IE browser
object model, sometimes do return 'unknown' from typeof,
I have made a test case
<http://home.arcor.de/martin.honnen/javascript/typeofTest1.html>
and it shows no difference in terms of 'unknown' results for me between
IE 6 and IE 7 beta 3. Only testing typeof on a property/method of an
ActiveX object gives 'unknown' and that has been known (pun intended)
before IE 7.
And ECMAScript edition 3 (11.4.3 The typeof Operator) for host objects
and typeof says
"Object (host) Implementation-dependent"
so an implementation is allowed to yield something different than the
predefined values 'undefined', 'number', 'boolean', 'string', 'object',
and 'function' in this case.

--

Martin Honnen
http://JavaScript.FAQTs.com/
Jul 27 '06 #8
JRS: In article <44c75b61$0$23525$5a62ac22@per-qv1-newsreader-
01.iinet.net.au>, dated Wed, 26 Jul 2006 22:07:39 remote, seen in
news:comp.lang.javascript, RobG <rg***@iinet.net.auposted :
>Klaus Johannes Rusch wrote:
>>
IE7 returns "unknown" instead of "undefined" when querying the type of
an unknown property of an object, for example

document.write(typeof window.missingproperty);

Has "unknown" been defined as a valid return value for the typeof
operator in a later version of ECMAScript or is this a JScript "feature"?

No to ECMAScript, yes to JScript - Microsoft added it to version 8,
along with 'date'.

I wonder whether IE7 counts my Inc1T as being an unknown property of an
object, if the include file defining it is not found?
From the FAQ, I take it that the term JScript includes the scripting
language in Microsoft's Web browsers.

<FAQENTRYISTM that, in the FAQ, it would be useful to have an
indication of the differences between JScript and ECMA-232 3rd Edn -
probably as an example entry with a link to Notes or elsewhere.

JScript "unknown" and "date" might be a good example.

--
© John Stockton, Surrey, UK. ?@merlyn.demon.co.uk Turnpike v4.00 IE 4 ©
<URL:http://www.jibbering.com/faq/>? JL/RC: FAQ of news:comp.lang.javascript
<URL:http://www.merlyn.demon.co.uk/js-index.htmjscr maths, dates, sources.
<URL:http://www.merlyn.demon.co.uk/TP/BP/Delphi/jscr/&c, FAQ items, links.
Jul 27 '06 #9
JRS: In article <X_******************************@comcast.com>, dated
Wed, 26 Jul 2006 15:34:21 remote, seen in news:comp.lang.javascript,
Randy Webb <Hi************@aol.composted :
>Dr John Stockton said the following on 7/26/2006 8:42 AM:
>JRS: In article <4i************@individual.net>, dated Wed, 26 Jul 2006
00:06:37 remote, seen in news:comp.lang.javascript, Klaus Johannes Rusch
<Kl********@atmedia.netposted :
>>IE7 returns "unknown" instead of "undefined" when querying the type of
an unknown property of an object, for example

document.write(typeof window.missingproperty);

Has "unknown" been defined as a valid return value for the typeof
operator in a later version of ECMAScript or is this a JScript "feature"?
>My pages use such as
if (typeof(Inc1T)=='undefined') alert('File include1.js top fault, RSVP!')
with Inc1T=0 being defined at the top of file include1.js.

Why typeof? Why not just if(Inc1T). Depending on how Inc1T is defined
though.
Evidently you have once more incorrectly assumed understanding on your
own part. Depending on circumstances, either Inc1T is defined or it is
not defined; TINA. If it's defined, all is (so far) well; no alert is
required. Its value is not used.

If it is not defined, I want to give my own specific recognisable
warning; I don't want the general use-of-undefined warning since that
could occur for other reasons elsewhere in the code : remember, this is
a Web application, so messages can be read by those other than the
author.

>If this rather stupid change is confirmed,

It is not a "stupid change", it actually makes sense.
Had it been introduced at the birth of Javascript, using "unknown" would
have been slightly better than using "undefined"; but to make such a
change, when in ECMA-263 3rd Edn "undefined" is defined and "unknown"
does not appear, is either ludicrous or a malicious commercial move.
Changing the set of results possible from typeof is unnecessary; it is
sufficient to have a new feature getType which returns the fuller
detail.
--
© John Stockton, Surrey, UK. ?@merlyn.demon.co.uk Turnpike v4.00 IE 4 ©
<URL:http://www.jibbering.com/faq/>? JL/RC: FAQ of news:comp.lang.javascript
<URL:http://www.merlyn.demon.co.uk/js-index.htmjscr maths, dates, sources.
<URL:http://www.merlyn.demon.co.uk/TP/BP/Delphi/jscr/&c, FAQ items, links.
Jul 27 '06 #10

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

Similar topics

24
by: Charles Crume | last post by:
Hello; My "index.htm" page has 3 frames (content, navigation bar, and logo). I set the "SRC" of the "logo" frame to a blank gif image and then want to change it's contents after the other two...
7
by: Irakl Gordin | last post by:
this.opener is not null but everything inside it is "uknown". How should I interpret it? *** Sent via Devdex http://www.devdex.com *** Don't just participate in USENET...get rewarded for it!
10
by: Roland | last post by:
Hello, the example code is the following(the number in parentheses at the beginning are just for reference)(The complete HTML file is at the end of this article): (1)window.location =...
3
by: Paul T. Rong | last post by:
Do "" and Null both mean nothing?¡¡ If I don't type anything in text box, the its value is Null£¿¡¡Or it is ¡°¡±£¿ I don¡¯ think they are the same, but I don¡¯t know their difference. Thanks.
35
by: David Cleaver | last post by:
Hello all, I was wondering if there were some sort of limitations on the "if" statement? I'm writing a program which needs to check a bunch of conditions all at the same time (basically). And...
188
by: infobahn | last post by:
printf("%p\n", (void *)0); /* UB, or not? Please explain your answer. */
7
by: jccorreu | last post by:
I've got to read info from multiple files that will be given to me. I know the format and what the data is. The thing is each time we run the program we may be using a differnt number of files,...
3
by: Aaron | last post by:
I'm trying to parse a table on a webpage to pull down some data I need. The page is based off of information entered into a form. when you submit the data from the form it displays a...
20
by: Prisoner at War | last post by:
Hi, People, Is it possible to have an "empty" or "dummy" <a href***without*** the browser jumping back up the page?? I have a hyperlink that doesn't point to another document, but is used to...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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...

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.