对象操作-对象属性赋值

Benchmark created on


Test runner

Ready to run.

Testing in
TestOps/sec
对象字面量方式
const Person = {}
Person.name = 'a'
Person.age = 0
Person.getName = function() {
  return this.name
}
ready
Object.defineProperty() 方式
const Person = {};
Object.defineProperty(Person, 'name', {
  value: 'a',
  writable: true
});
Object.defineProperty(Person, 'age', {
  value: 0,
  writable: true
});
Object.defineProperty(Person, 'getName', {
  value: function () {
    return this.name
  }
});
ready

Revisions

You can edit these tests or add more tests to this page by appending /edit to the URL.