如何知道 Java 脚本中的对象值

How to know the object value in Java Script

嗨,我可以在控制台中打印 'bookingPreferences' 值吗?

let bookingPreferences = {
      destination: hotel.ancestorDestination.name.toLowerCase (),
      destinationId: hotel.ancestorDestination.shortId,
      checkInDate: new moment ().add (dateCount, (dateScale.includes ('month') ? 'months' : 'days')).format ('YYYY-MM-DD'),
      checkOutDate: new moment ().add (dateCount, (dateScale.includes ('month') ? 'months' : 'days')).add (6, 'days').format ('YYYY-MM-DD'),

      partyMix: {
        adultCount: 1,
        childCount: 0,
        nonAdultAges: []
      },
      resortId: hotel.id
    };

我试过 var value= JSON.stringify ('bookingPreferences' + bookingPreferences);

这没有帮助。请告诉我知道值嵌套对象值的方法是什么?

您需要将要传递的酒店对象导入 bookingPreferences。然后一个简单的 console.log(bookingPreferences) 就可以解决问题。