鉴于课程:
let day = new Day()
我有day instanceof Day
并通过几个函数调用传递它。
但后来我用console.log(day)
检查了这个对象,它返回false。
当我在Chrome中Day {_moment: Moment, year: 2016, month: 9, day: 17}
时,我得到day instanceof Day
。
在我使用instanceof检查之前,在控制台日志中使用Day前缀无法弄清楚为什么console.log('Day: ', day)
console.log('Day: ', typeof day)
console.log('Day: ', day instanceof Day)
返回false。
有什么想法吗?
编辑:
Day: Day {_moment: Moment, year: 2016, month: 9, day: 17}
_moment: Moment
day: 17
month: 9
year: 2016
__proto__: Object(anonymous function)
Day: object
Day: false
输出:
_id
答案 0 :(得分:2)
@Bergi was correct, in one import of the Day class I wrote: import Day from '../lib/Day'
Webpack then generated another type of Day that was being used in that part of my codebase. Tip: always use lower case string on imports and require.