Skip to main content

Objects

  • using functions as methods A function defined on an object is called a method.
  • methods can be added via constructor function or object.prototype
  • Recursion Object: a collection of key and value pairs

Constructor

Constructors are defined with a capitalized name to distinguish them from other functions that are not constructors. Constructors use the keyword this to set properties of the object they will create. Inside the constructor, this refers to the new object it will create. Constructors define properties and behaviors instead of returning a value as other functions might.

Intrinsic Objects

  • Error
  • Function
  • Global
  • JSON
  • RegExp
  • Date
  • Math

Since JavaScript is a language that can work in multiple environments, the code itself may have to act differently in different environments. To illustrate, there may be things in the browser like history or location that will not be available on the server. There may also be other environments like mobile devices that have unique capabilities.

Native Objects

  • built-in to ECMAScript and defined independent of the environment
  1. Object
  2. Array
  3. Promise
  4. JSON

Host Objects

  • host objects are part of the environment that your code runs in.
  1. Window
  2. Document
  3. History
  4. Navigator

Delete object property

https://www.w3schools.com/howto/howto_js_remove_property_object.asp

https://levelup.gitconnected.com/5-facts-about-delete-operator-in-javascript-c16fd2588cd