0

I try to apply arguments to Date, but its not work. How I can apply arguments to native constructor Date? I tried:

var a = new (Date.bind.apply(Date, ['2010-10-10']))();

and

var a = new Date();
Date.apply(a, ['2010-10-10']);
4
  • Perhaps you can expand on what exactly you are trying to achieve? Commented Sep 1, 2013 at 9:02
  • Felix, I tried one of those methods and its not work. You can try it youself new (Function.prototype.bind.apply(Date, ['2010-10-10'])); Commented Sep 1, 2013 at 9:08
  • Check This Solution [javascript-object-by-calling-prototype-constructor-apply][1] [1]: stackoverflow.com/questions/181348/… Commented Sep 1, 2013 at 9:21
  • It works fine for me: jsfiddle.net/pNdHT. Granted, your code looks pretty much the same, I cannot find the problem. Commented Sep 2, 2013 at 5:28

1 Answer 1

1

If the parameter you are using defines a specific date, just use the usual new Date() constructor:

var a = new Date( '2010-10-10' );
Sign up to request clarification or add additional context in comments.

2 Comments

No. I need to create wrapper to Date and wrapper class can gets any params such as Date can get. Like ts, ISOString or year, month, date, etc.
@asci You should edit your question and elaborate some more on what you exactly want to achieve.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.