DoneJS StealJS jQuery ++ FuncUnit DocumentJS
3.0.0
2.3.27

 

  • Github
  • Twitter
  • Chat
  • Forum
  • Guides
  • Core
    • can-component
    • can-compute
    • can-connect
    • can-define
      • static
        • types
      • types
        • PropDefinition
      • behaviors
        • Type
        • Value
        • get
        • serialize
        • set
        • type
        • value
    • can-define/list/list
    • can-define/map/map
    • can-route
    • can-route-pushstate
    • can-set
    • can-stache
    • can-stache/helpers/route
    • can-stache-bindings
  • Ecosystem
  • Infrastructure
  • Legacy
  • Bitovi
    • Bitovi.com
    • Blog
    • Consulting
    • Training
    • Open Source
  • Chat
  • Forum
  • Star
  • Follow @canjs
  • CanJS
  • /
  • Core
  • /
  • can-define
  • /
  • Value
  • / On this page
    • Value

      function

      Provides a constructor function to be used to provide a default value for a property.

      • source

      Value

      A constructor function can be provided that is called to create a default value used for this property. This constructor will be invoked with new for each created instance. The default value is created on demand when the property is read for the first time.

      Specify Value like:

      prop: {
          Value: Array
      },
      person: {
          Value: Person
      }
      

      Use

      var Address = DefineMap.extend({
          street: {type: "string", value: "321 Longbow"},
          city: {type: "string", value: "Dallas"}
      });
      
      var Direction = DefineMap.extend({
          from: {Type: Address, Value: Address},
          to: {Type: Address, Value: Address}
      });
      
      var direction = new Direction({
          to: {street: "2070 N. Stave"}
      });
      
      direction.from.street //-> "321 Longbow"
      direction.to.street   //-> "2070 N. Stave"
      

      CanJS is part of DoneJS. Created and maintained by the core DoneJS team and Bitovi. Currently 3.0.0.