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 7647709
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T10:31:51+00:00 2026-05-31T10:31:51+00:00

Setting a property descriptor like this: Object.defineProperty(window, ‘someFunction’, { value: function() { alert(‘safe’); },

  • 0

Setting a property descriptor like this:

Object.defineProperty(window, 'someFunction', {
    value: function() { alert('safe'); },
    writable: false,
    enumerable: false,
    configurable: false
});

…should, as far as I know, make the someFunction property of window non-writable. It works for function expressions as I expect, whether the function is directly assigned to the object property… fiddle

window.someFunction = function() { alert('boom!'); }
someFunction(); // safe

…or assigned to a global variable: fiddle

var someFunction = function() { alert('boom!'); }
someFunction(); // safe

However, it doesn’t seem to work with function declarations: fiddle

function someFunction() { alert('boom!'); }
someFunction(); // boom!

Is this behavior intentional? What is the reasoning behind it? Is this documented anywhere? Or am I just making some kind of silly mistake?


By the way, I’m using Chromium 17 to test this. Strict mode doesn’t seem to make any difference.

  • 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. Editorial Team
    Editorial Team
    2026-05-31T10:31:52+00:00Added an answer on May 31, 2026 at 10:31 am

    This is a bug (see Bug #115452), which I also encountered when answering this question.

    Compatibility check: Test case

    • In Firefox 4+, it works fine.
    • In Chrome 16, it works fine.
    • In Chrome 17, it does not work.
    • IE8- doesn’t have Object.defineProperty, so it doesn’t work
    • In IE9, it does not work.
    • In Safari 5, it does not work.
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Can this be done by setting a property? I'd prefer that approach then to
I'm looking for help setting a new default property value for an inherited control
I am Setting Google Calendar via python command like this def _InsertQuickAddEvent(self, content=Tennis with
https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Object/defineProperty states: configurable : True if and only if the type of this property
How to enumerate items of Spark List component after setting dataProvider property? I mean
I tried setting the defaultvalue property of the field to Guid.NewGuid() but every item
If I am setting the Text property of a Form from a non-UI thread,
I can never remember the order of the shorthand property for setting the margin
I'm creating a GroupBox at runtime and setting its Text property. Usually, the text
In a .aspx web page, by setting a textbox's text property by code in

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.