1.2.6.1.初始化

  • 初始化的方式

    • 物件實體 (object literals)

      • 很適合做為測試API時的資料來源

        var people = [
        {
          // the 'john' object
          firstname: 'John',
          lastname: 'Doe',
          address: [
              '111 Main st',
              '222 Main st'
          ]
        },
        {
          // the 'jane' object
          firstname: 'Jane',
          lastname: 'Doe',
          address: [
              '333 Main st',
              '444 Main st'
          ],
          greet: function() {
              return 'Hello';
          }
        }
        ]

Last updated