function now(){
return +new Date;
}
questions :
- what does the plus sign mean?
- when can you create a new object with a constructor function but without the following parentheses, such as
new Datebut notnew Date()
great thanks!
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
1 . The plus sign is the unary + operator.
That expression is equivalent to cast the Date object to number:
2 . If you don’t add the parenthesis, the new operator will call the object type (Date) parameterlessly