1
var o = {}; // Creates a new object

Example of an object property added with defineProperty with a data property descriptor

Object.defineProperty(o, "a", {value : 37,
                               writable : true,
                               enumerable : true,
                               configurable : true});

How to implement for IE7-8?(with attributes writable,enumerable,configurable)

Sirko
  • 72,589
  • 19
  • 149
  • 183
lazer09
  • 23
  • 4
  • 1
    According to [MDN](https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Object/defineProperty#Browser_compatibility) there is (almost) no support in IE before IE9. – Sirko Sep 26 '12 at 14:21
  • 1
    You can't, not really... read [check the list here](http://kangax.github.com/es5-compat-table/), and [check this question, too](http://stackoverflow.com/questions/4819693/working-around-ie8s-broken-object-defineproperty-implementation) for some extra info – Elias Van Ootegem Sep 26 '12 at 14:24

1 Answers1

0
if (!Object.defineProperty) {
        Object.defineProperty = function (obj, prop, descriptor) {
            if (arguments.length < 3) { // all arguments required
                throw new TypeError("Arguments not optional");
            }

            prop += ""; // convert prop to string
            ...     
Beacon
  • 11