View Full Version : hide prototype from enumeration
01-26-2006, 06:00 AM
are there built-in methods to keep a prototyped method of a public class private?
for(var i in arr)str+=arr[i];
alert(str);//gives back the elements and the function definitiontyia
01-26-2006, 06:12 AM
No, but you can use Object.prototype.hasOwnProperty to tell if a property is inherited or not in the actual loop body.
But then again, why are you using the for..in loop on an array instead of a plain for loop with a numeric iterator variable?
01-26-2006, 07:12 AM
why are you using the for..in loop on an array instead of a plain for loop with a numeric iterator variable?
it was just an example - having said that, it's not that out of the realm of feasibility - i'll often construct arrays as hash tables to use both associative and integer access - the added weight of array methods is neglible.
as regards the original question -
flash's proprietary actionscript has a method (ASSetPropFlags) that allows you to prototype core classes at will and hide whatever bits and pieces you wish from iteration. i had hoped for something similiar or a setter to the getter of isPropertyEnumerable.
01-26-2006, 08:13 AM
01-26-2006, 08:17 AM
thanks for your help as always liorean
02-03-2006, 04:10 PM
I just wanted to say thank you for this thread :D i don't like the answer, but it was just the thread i was looking for.
Powered by vBulletin® Version 4.2.2 Copyright © 2015 vBulletin Solutions, Inc. All rights reserved.