473,325 Members | 2,872 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,325 software developers and data experts.

How to Tell if myObj.constructor is Enumerable in IE / JScript?

I think this is not possible...
var fnProto = Function().prototype;
var badAss = { constructor : "Chuck Norris" };

result = [
isConstructorEnumerable( fnProto )
,isConstructorEnumerable( badAss )
];
function isConstructorEnumerable( ocean, pacific ) {
var enumerable = false;
// hmmm.
// enumerable = ocean.propertyIsEnumerable( pacific );

return enumerable;
}

expected result: [ false, true ];

Has to work in IE. It seems the only way to tell would be if there's
something else that IE adds to the object constructed in Steps 9-10 of
section 13.2 Creating Function Objects

http://bclary.com/2004/11/07/#a-13.2.2

Unfortunately, IE doesn't properly check the DontEnum flag, so will
return the wrong result for propertyIsEnumerable.

Sep 26 '07 #1
1 1772
dh**********@gmail.com wrote:
>I think this is not possible...
var fnProto = Function().prototype;
You have assigned a reference to the object that is the prototype
property of a new function object returned by - Function() - to the -
fnProto - variable.
var badAss = { constructor : "Chuck Norris" };

result = [
isConstructorEnumerable( fnProto )
Your - isConstructorEnumerable - has two formal parameters, yet you are
only passing one argument to it.
,isConstructorEnumerable( badAss )
];
function isConstructorEnumerable( ocean, pacific ) {
var enumerable = false;
// hmmm.
// enumerable = ocean.propertyIsEnumerable( pacific );

return enumerable;
This function will always return false, as it contains no code that will
change the value assigned to - enumerable.
}

expected result: [ false, true ];
Given the code posted the expected results should be [false, false], but
you did not say what the actual results were.
Has to work in IE.
<snip>

What makes you think it does not 'work' in IE?

Richard.

Sep 26 '07 #2

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

Similar topics

1
by: Christopher Benson-Manica | last post by:
I'd like to add a method foo() to all objects: Object.prototype.foo=function() { // whatever } The caveat, though, is that I do not want foo to be enumerable by a for-in loop. Can I do...
4
by: Andreas Klemt | last post by:
Hello, what has the better performance and what are you using? Dim myObj As Object = 70 a) Dim myInt As Integer = DirectCast(myObj, Integer) b) Dim myInt As Integer = Convert.ToInt32(myObj) ...
26
by: Patient Guy | last post by:
The code below shows the familiar way of restricting a function to be a method of a constructed object: function aConstructor(arg) { if (typeof(arg) == "undefined") return (null);...
12
by: satyajit | last post by:
I am trying to learn the concept of constructors in ECMAScript. I executed following code (See execution in Rhino JavaScript shell): function Foo(a) { this.a = a; } function Bar(b) { this.b...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...

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.