James111 James111 - 4 months ago 22
Javascript Question

How can I access a nested class object in Javascript?

I'm using the node scheduler & it creates an object like so:

recurs: true,
year: null,
month: null,
date: null,
dayOfWeek: null,
hour: null,
minute: Range { start: 0, end: 59, step: 2 },
second: 0

How can I access the

When I use
, node throws the following error:

TypeError: Cannot read property 'step' of undefined

I've also tried
which is the same as what I tried above.


When you're logging objects in Node, a class name immediately preceding an object tells you want class that object is.

So in your case, when Node logs

   minute: Range { start: 0, end: 59, step: 2 },

It actually means that the object you're printing is a plain object, which has a property minute (of type Range) with its own properties start, end and step.

So to refer to step, you have to use minute.step.