Talk:JavaScript/Functions

(random heading)
(inserted for readability Rursus (talk) 20:44, 18 May 2010 (UTC))

Firefox 1.5 and Opera 8.5 shows 105 and 108 instead if 2005 and 2008 for the code:

var mydate = new Date; document.write(mydate.getYear); document.write("&lt;br&gt;&lt;br&gt;"); mydate.setYear(2008); document.write(mydate.getYear);

That's why we should always use getFullYear instead of getYear, as recommended by
 * http://msdn.microsoft.com/library/default.asp?url=/library/en-us/jscript7/html/jsmthgetfullyear.asp
 * http://www.devguru.com/technologies/javascript/10590.asp
 * http://www.webreference.com/js/tips/000707.html

Perhaps there are some ideas and tips in http://c2.com/cgi/wiki?CategoryJavaScript we could paraphrase in this Wikibook, such as, for example, http://c2.com/cgi/wiki?PrivateVariablesInJavaScript .

-

Is there a place in this Wikibook for these techniques?


 * Aspect-oriented-programming in JavaScript in 20 lines of code http://www.jroller.com/comments/deep?anchor=aop_fun_with_javascript


 * continuations in JavaScript http://levelplusplus.blogspot.com/2004/07/continuations-in-mozilla.html

-

I don't find interjections like "That wasn't very hard, was it?" or "Don't let Bill Gates know -- he'll patent it!" to be helpful. To me they seem silly and childish -- but then I don't like the "Dummies" books either. What do other people think?
 * The following has been removed due to its condescending nature, and general lack of coherentness.
 * "Now that wasn't very hard, was it? At this point, we are only using functions to save us some typing (actually, in the examples we used it is actually taking more typing - however, real-world programs will use the same function throughout the scripts.) When you learn about parameters, that's when functions really start to shine."
 * Pmw57 (talk) 13:04, 21 February 2009 (UTC)

-

The Classes section had the following at the start of some code: var site = new Object; //Required to not cause error in Internet Explorer site = {};

As the error hasn't been able to be duplicated from IE3 to IE7, more details about the error need to be provided. The code now starts with var site = {}; Pmw57 (talk) 00:27, 22 February 2009 (UTC)

Merge
I suggest merging all of JavaScript/Functions into JavaScript/Functions and Objects. --DavidCary (talk) 03:43, 14 June 2009 (UTC)
 * I agree with you.--Sae1962 (discuss • contribs) 13:17, 18 March 2015 (UTC)
 * As there were no objections since 2009, I completed the merge and splitted the pages (see the table of contents).--Sae1962 (discuss • contribs) 14:23, 18 March 2015 (UTC)

Bad code!!
The code in the section this keyword is discouraged according to the link under Further reading, because it creates methods as objects for totalValue, addQuarters and addDollars again and again for each object. The link provided instead explains another coding style that makes any OOPL programmer cry in despair! One has to create a "parent" type and then assign a predefined prototype property with that "parent" type. D*rn!! Rursus (talk) 20:44, 18 May 2010 (UTC)
 * Well, there is help for the OOPL programmer: to switch from an object-based language to an object-oriented one! :->--Sae1962 (discuss • contribs) 13:46, 18 March 2015 (UTC)