Jump to content

007Julien

Members
  • Posts

    5
  • Joined

  • Last visited

Everything posted by 007Julien

  1. It's a shame to choose, as you mentioned, a weird example for illustration !
  2. The first example is on w3schools.com site !
  3. I am not sure to understand the interest of this four variants ? Calculation times are probably the same and probably much lower than reaction times of users. Only the form, seems to favour the choice of solutions 2 or 4 ? The only question is : Can we expect a change in the page of the site never to see this awful code ?
  4. Fortunately that is not the Saints schedule!
  5. This exemple is : Date.prototype.myMet=function(){if (this.getMonth()==0){this.myProp="January"};if (this.getMonth()==1){this.myProp="February"};if (this.getMonth()==2){this.myProp="March"};if (this.getMonth()==3){this.myProp="April"};if (this.getMonth()==4){this.myProp="May"};if (this.getMonth()==5){this.myProp="June"};if (this.getMonth()==6){this.myProp="July"};if (this.getMonth()==7){this.myProp="August"};if (this.getMonth()==8){this.myProp="Spetember"};// With a typo for September !if (this.getMonth()==9){this.myProp="October"};if (this.getMonth()==10){this.myProp="November"};if (this.getMonth()==11){this.myProp="December"};} // Make a Date object, then call the myMet method: var d = new Date(); d.myMet(); var monthname = d.myProp;// The result of monthname will be: August // It there not a better way to use an array with something like this ?Date.prototype.getLitteralMonth=function(){ return "January,February,March,April,May,June,July,August,September,October,November,December".split(',')[this.getMonth()];}alert(d.getLitteralMonth()) That is not scripting but writing guessing ! At least the proposed method has the merit to justify the numbering of months from 0 to 11 without imposing 12 unnecessary tests ! Since your site is very useful. Thanks...
×
×
  • Create New...