Home › Forums › JavaScript › Days of the Week › Reply To: Days of the Week
November 28, 2013 at 3:29 pm
#157326
Participant
My Question is can these two lines be combined?
very simply:
var weekday = new Date().getDay();
This is called “method chaining.” Since functions are first-class (and, since functions are objects) in javascript, this will work any time the function/method on the left (e.g., Date
) returns an object that has the method/property on the right (e.g., getDay
).