0

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 minute.Range.step value?

When I use minute.Range.step, node throws the following error:

TypeError: Cannot read property 'step' of undefined

I've also tried minutes.Range["step"] which is the same as what I tried above.

5
  • minute.step or minute["step"]. Commented Oct 4, 2016 at 0:19
  • 2
    .minute.step? Why are you using Range? Commented Oct 4, 2016 at 0:21
  • Whoops, I accidentally typed the wrong value when writing up my question @Amadan - I edited the question to show what I actually tried Commented Oct 4, 2016 at 0:22
  • @Oriol Tipped me off, thanks. I thought you had to access the properties via the Range object. Commented Oct 4, 2016 at 0:26
  • minute is the Range object. Commented Oct 4, 2016 at 0:35

1 Answer 1

1

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.

Sign up to request clarification or add additional context in comments.

1 Comment

Thanks for clarifying! I will delete my answer as yours goes into a bit more detail :)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.