0

In Chrome you can do:

date = new Date();

and then in the console you can do:

hour:date.getHours();

What is this called? Where else does it work?

I saw this in the follow code:

showDateTimePicker(date, callback) {
    date = date || new Date();
    var options = {
        ...this.props,
        year:date.getFullYear(),
        month:date.getMonth(),
        day:date.getDate(),
        hour:date.getHours(),
        minute:date.getMinutes()
    };
    RCTDateTimePicker.showDateTimePicker(options, function (year, month, day, hour, minute) {
        date.setFullYear(year);
        date.setMonth(month);
        date.setDate(day);
        date.setHours(hour);
        date.setMinutes(minute);
        callback(date);
    });
}
0

1 Answer 1

3

hour:date.getHours(); and var options = {hour:date.getHours()}; are two very different statements.

The former is a label which is designed so that when you have nested loops and want to break or continue from one of them, you can specify which. Putting it before a function call is useless.

The latter is an object initialiser which allows you to specify the name and values of properties on a new object.

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

1 Comment

wowza, I must have been up waaay too late or something. for some reason the lack of spaces on either side of the colon had me thinking it was a whole different concept. That and I was fresh off looking at android XML which had something like android:timePickerMode="spinner"

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.