Skip to content

Instantly share code, notes, and snippets.

@sharmasourabh
Created November 8, 2017 06:26
Show Gist options
  • Save sharmasourabh/88c330d59257bb4198f4413f5b04cd65 to your computer and use it in GitHub Desktop.
Save sharmasourabh/88c330d59257bb4198f4413f5b04cd65 to your computer and use it in GitHub Desktop.
  1. Javascript is object oriented. Till, ECMAScript 5, no class was available in javascript. You need to play with objects for achieving the class
  2. Due to same above reason, properties of objects(class) could be modified later, which is in contrast to other languages. Like in Java once class is delcared you can not change its properties.
  3. Javascript uses the internal Put method to add new own property on the object. Own properties are different from prototype properties.
  4. Each function is an object. Also, functions are first class Functions. Javascript uses function's internal method call to differentiate it from other type of objects.
  5. Internal method Set is used when a new value is assigned to existing property.
  6. Internal method Delete is called when a delete operation is performed on an object like delete employee.address.
  7. props in object would enumerate all properties including the prototype (for which Enumerable attribute is set to true). Object.keys(object) only returns the array of object's own properties.
  8. Prior to ECMAScript 5, there was no way to interact with internal properties of object.
  9. You would get an error if you define a property with both data and accessor attributes. Object.defineProperty(object, prop, { value: "pValue", writable: true ... }).
  10. Object.preventExtension() allows removal of own properties, but Object.seal() doesn't.
  11. Object.freeze() freezes the object and does not allow any change, not even a change of value of its own property.
  12. One should not modify the Object.prototype, Object.prototype must not be modified as all objects use it. Therefore, whatever change you add, it would be available to all objects, irrespective that is applicable there or not. Another side effect is... enumeration. enumberable is true for new property, therefore it would be available when for(prop in object) would be used.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment