bannerbannerbannerbannerbanner
Jova wiki   tid   Login/Logout

RSS

Navigation





Quick Search
»
Advanced Search »

PoweredBy

Everything is an object - Allt är objekt

In Javascript everything is an object; apart from the following basic datatypes: strings, numbers, booleans, null and undefined. Objects can be seen as belonging to specific categories. They are:
  • native objects - objects provided by Javascript
  • host objects - objects provided by the hosting context, e.g. a web browser
  • user-defined objects - objects that are created in code by the user (programmer)

Objects - Objekt

An object is a collection of properties. Objects are handled as references, not as values. Each object also contains a set of object attributes:
  • prototype - referens to an object that is inherited, who's properties are also part of this object
  • class - a string that identifies an objects "identity"
  • extensible - a flag indicating whether one can att properties to this object

Creating an object

Objects are created by one of three ways:
  1. object literal - a comma-separated list of propertyname-and-value-pairs separated by colon : var theName = { x:1, "main title":"An awesome title" }
  2. using the new operator - calling a constructor function with new : var theName = new NewObject()
  3. using the create function - calling the create-function using the prototype and properties for the new object : var theName = Object.create({x:1}, {y:2, z:3})

Jova wiki is © Jovall