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

Final properties and methods?

VK
If any way to implement a cross-browser method/property protection in an
object?

Say:

function myObject() {
this.myProperty = "A value that shouldn't be overridden in instances."
}

Mozilla (I believe) still has watch() method, that does the job semi-ok (you
cannot really protect a property, but you can immediately restore its
original value).

IE doesn't have watch() method though.
Jul 23 '05 #1
2 1250
VK wrote:
Mozilla (I believe) still has watch() method, that does the job semi-ok (you
cannot really protect a property, but you can immediately restore its
original value).


Actually Mozilla also supports constants which might work out better:
const foo = "A value that shouldn't be changed";
Unfortunally Internet Explorer doesn't understand the const keyword
and will therefore make an error.
Jul 23 '05 #2
On Sat, 11 Dec 2004 12:40:59 +0100, Ulrik Skovenborg <"skovenborg at frac
dot dk"> wrote:

[snip]
Unfortunally Internet Explorer doesn't understand the const keyword


Neither does Opera, and I doubt many other browsers (if any) will, either.

To VK: No, you can't mark properties as read-only. You'll either have to
trust client software to respect a "Don't modify this value" notice, or
hide the value internally and use a function. Go with the former, if you
can.

Mike

--
Michael Winter
Replace ".invalid" with ".uk" to reply by e-mail.
Jul 23 '05 #3

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

Similar topics

2
by: G. Ralph Kuntz, MD | last post by:
Step on my soapbox... :-) I believe that the "final" keyword is underused in Java. I have gotten into the habit of using it on EVERY method parameter, instance variable, and local variable...
0
by: Anthony Baxter | last post by:
To go along with the 2.4a3 release, here's an updated version of the decorator PEP. It describes the state of decorators as they are in 2.4a3. PEP: 318 Title: Decorators for Functions and...
14
by: Medi Montaseri | last post by:
Hi, I think my problem is indeed "how to implement something like java's final in C++" The long version.... I have an abstract base class which is inherited by several concrete classes. I...
3
by: ytrewq | last post by:
Should dynamic ("expando") properties be restricted to native and user-defined objects? Or should host objects - such as references to the browser or a plug-in or to the document and its elements -...
23
by: Marcin Grzębski | last post by:
I red MSDN article of C# 2.0 this week... and i found very strange syntax for properties e.g.: public int MyIntValue { get { // ... } protected set { // ... }
3
by: Sam Sungshik Kong | last post by:
Hello! While using panel control, I wondered a thing. Panel class is subclass of Control class. Control class has KeyPress event and Focus() method, etc... Then Panel class must have them. I...
4
by: Willy Denoyette [MVP] | last post by:
C# Final Working Draft April 2005 from Ecma TC39/TG2 http://www.plumhall.com/CSharpFinalWorkingDraftApril2005.pdf Willy.
17
by: Bruce One | last post by:
Lets consider a class called Currency. This class must be the responsible for taking care of all calculations over currency exchanges, in such a way that I pass values in Euros and it returns the...
39
by: Paul Mcilreavy | last post by:
Hi, i would like to get some view points on the use of properties within classes. My belief is that properties should generally be used to return values of private members. They should not do...
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: 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
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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...
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,...
0
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
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,...

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.