Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on May 6th, 2012  |  syntax: None  |  size: 0.56 KB  |  hits: 23  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. Difference between this property descriptor and property assignment in ECMAScript 5?
  2. var Person = {
  3.     firstName: null, // the person’s first name
  4.     lastName: null // the person’s last name
  5. };
  6.        
  7. var Employee = Object.create(Person, {
  8.     id: {
  9.         value: null,
  10.         enumerable: true,
  11.         configurable: true,
  12.         writable: true
  13.     }
  14. });
  15.        
  16. var Employee = Object.create(Person);
  17. Employee.id = null;
  18.  
  19. // Or using jQuery.extend
  20. $.extend(Employee, {
  21.     id : null
  22. });
  23.        
  24. obj.prop = val;
  25.        
  26. Object.defineProperty( obj, 'prop', {
  27.     value: val
  28. });