Tsukasa
Tsukasa

Reputation: 6562

Permission Denied setting variable

I'm trying to figure out a very random error in an application that the vendor seems to be having an issue correcting as well so this is more so a question to help me understand different scenarios that could be causing this problem in a js world.

It is a Javascript based error of 'Permission Denied'

The line being reported as the problem is just setting a variable to false.

<script LANGUAGE="JavaScript" for='tdNote' event='onclick'>
    if (this.firstChild.src.indexOf('icon_blank.gif') != -1) return;
    if(mbInNoteClick || mbInGridClick) return;

    mbInNoteClick = true;
    onGridClick(this.parentElement.rowIndex);
    onNoteIconClick(this.parentElement.rowIndex);
    mbInGridClick = false; //THIS LINE IS REPORTED AS PERMISSION DENIED
    mbInNoteClick = false;
    window.event.cancelBubble = true;
</script>

The page containing this code doesn't have this variable so I assume this is set globally somewhere. (large application)

if it was accessible in the if statement, what scenarios would cause a permission denied when trying to set a variable?

Upvotes: 1

Views: 330

Answers (1)

mario ruiz
mario ruiz

Reputation: 996

The property is a constant or tagged as immutable, mainly it means a non-writable property because it was defined like this:

Object.defineProperty( myObject, "a", {
  value: 4,
  writable: false,  // not writable! 
  configurable: false, // not configurable!
} );

From the js master Kyle Simpson in his book : "You Don't Know JS- this & Object Prototypes"

There’s a nuanced exception to be aware of: even if the property is already configurable:false, writable can always be changed from true to false without error, but not back to true if already false.

The if condition code is reading it, that's why You have read access.

Also there are other methods to declare permission over properties like: Object.preventExtensions, Object.seal, Object.freeze,

Upvotes: 1

Related Questions