Error: permission to access property category '

I cannot figure out why I am getting the following console error in Firefox 34 with Firebug 2.0.7. This is a simple block of code. It works great in Safari, Chrome and IE.

"Error: permission denied to access property category 'myscript.js (line 7)"

var MyMaterials = function() {
var category, material;
return console.dir(this);
}

record_1 = new MyMaterials;
record_1.category = "Clear Film";
record_1.material = "Opticlear PC 5000";

console.log(record_1.category);
console.log(record_1.material);

      

+3


source to share


1 answer


The solution is simple. Stop refund console.dir(this)

.

When you return a non-primitive in a constructor, you get that value instead of an object instance. console.dir

returns some other object that is not an instance of an object and throws this error, at least in Firebug, anyway, the native developer tools don't seem to have this problem.



Fixed code:

var MyMaterials = function() {
var category, material;
console.dir(this);
}

record_1 = new MyMaterials;
record_1.category = "Clear Film";
record_1.material = "Opticlear PC 5000";

console.log(record_1.category);
console.log(record_1.material);

      

+1


source







All Articles