Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 87041
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 10, 20262026-05-10T22:20:26+00:00 2026-05-10T22:20:26+00:00

Looking at the mozilla documentation , looking at the regular expression example (headed "Creating

  • 0

Looking at the mozilla documentation, looking at the regular expression example (headed "Creating an array using the result of a match"), we have statements like:

input: A read-only property that reflects the original string against which the regular expression was matched.

index: A read-only property that is the zero-based index of the match in the string.

etc… is it possible to create your own object in JavaScript which will have read-only properties, or is this a privilege reserved to built-in types implemented by particular browsers?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. 2026-05-10T22:20:27+00:00Added an answer on May 10, 2026 at 10:20 pm

    Edit: Since this answer was written, a new, better way using Object.defineProperty has been standardized in EcmaScript 5, with support in newer browsers. See Aidamina’s answer. If you need to support ‘older’ browsers, you could use one of the methods in this answer as a fallback.


    In Firefox, Opera 9.5+, and Safari 3+, Chrome and IE (tested with v11) you can define getter and setter properties. If you only define a getter, it effectively creates a read-only property. You can define them in an object literal or by calling a method on an object.

    var myObject = {     get readOnlyProperty() { return 42; } };  alert(myObject.readOnlyProperty); // 42 myObject.readOnlyProperty = 5;    // Assignment is allowed, but doesn't do anything alert(myObject.readOnlyProperty); // 42 

    If you already have an object, you can call __defineGetter__ and __defineSetter__:

    var myObject = {}; myObject.__defineGetter__('readOnlyProperty', function() { return 42; }); 

    Of course, this isn’t really useful on the web because it doesn’t work in Internet Explorer.

    You can read more about it from John Resig’s blog or the Mozilla Developer Center.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 63k
  • Answers 63k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • added an answer You can do this by applying a CATransform3D to your… May 11, 2026 at 10:30 am
  • added an answer Define and declare are similar but assign is very different.… May 11, 2026 at 10:30 am
  • added an answer I use a combination of BlogEngine.NET, Windows Live Writer and… May 11, 2026 at 10:30 am

Related Questions

Looking at the mozilla documentation , looking at the regular expression example (headed "Creating
Looking at the C# project templates in VS2008 and the offerings are WPF User
Looking at the processmodel element in the Web.Config there are two attributes. maxWorkerThreads=25 maxIoThreads=25
Looking at the C# and VB.NET language specs I think it says that the
Looking at the cool new principles of software development: Agile You Ain't Gonna Need
Looking at the unicode standard , they recommend to use plain char s for
When looking at the myriad types of software written at our company, I instantly
I was looking at the API documentation for stl vector, and noticed there was
I'm currently looking at the Python framework Django for future db-based web apps as
I'm looking at the PHP Manual , and I'm not seeing a section on

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.