Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.javascript > #25727

Re: call function for times with different types

Newsgroups comp.lang.javascript
Subject Re: call function for times with different types
From "Evertjan." <exxjxw.hannivoort@inter.nl.net>
References <1c60d2a4-3634-4cae-ad31-dc2d38cc911c@googlegroups.com>
Date 2014-08-26 09:22 +0200
Message-ID <XnsA3955F56E2C50eejj99@194.109.133.133> (permalink)

Show all headers | View raw


=?UTF-8?B?5ZCz5pme5rWp?= <shwu.cs98@gmail.com> wrote on 26 aug 2014 in
comp.lang.javascript: 

> Hi, I was wondering in most of JavaScript programs. 

I do not believe you have even seen a tiny fraction of Javascript
programme scripts.

> Is there any
> practical usage to call a function many times and each time with
> different types? 

Ues, there is, because the programmer choose to make the function behave 
that way.

> Such kind of programs look awkward 

Those are not a "kind of programme" but just the whim of the programmer,
who likes a general function to behave slightly differently based on the 
parameter input, in stead of trying to remember a lot of different 
functions. This definitey may have its merits.

> but it somehow
> follows the grammar and JavaScript is a dynamic typed language. 

No, not as a dynamic typed language and it does not "follow the grammar".

Javascript just makes this possible as a *weak* typed language.

<http://en.wikipedia.org/wiki/Strong_and_weak_typing>
 
> A simple example would be:
> 
> function foo(a) {
> //do something here
>}

The a parameter is not even necessary, 
as all functions have an internal parameter collection:

function myFunction() {
   for(var i=0; i<arguments.length; i++)
      alert('Good morning, ' + arguments[i]);
};

Also in this example the parameter types can differ:

myFunction(23, 'Mr. Jones', employee(77), true)

[..]
> Thanks.

Could you please ad a signature or at least a nickname,
discussing with a nobody who seems to be named
=?UTF-8?B?5ZCz5pme5rWp?= is rather combersome 
and we would, be it slowly, come to know 
whether you are a strong or weak type of programmer.

-- 
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)

Back to comp.lang.javascript | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

call function for times with different types 吳晞浩 <shwu.cs98@gmail.com> - 2014-08-25 22:59 -0700
  Re: call function for times with different types "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2014-08-26 09:22 +0200
    Re: call function for times with different types "Christoph M. Becker" <cmbecker69@arcor.de> - 2014-08-26 09:44 +0200
      Re: call function for times with different types "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2014-08-26 10:11 +0200
        Re: call function for times with different types "Christoph M. Becker" <cmbecker69@arcor.de> - 2014-08-26 13:25 +0200
          Re: call function for times with different types Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2014-08-26 17:25 +0200
            [OT] Chinese given names (was: call function for times with different types) Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2014-08-27 01:40 +0200
          Re: call function for times with different types Denis McMahon <denismfmcmahon@gmail.com> - 2014-08-26 15:47 +0000
            [OT] Internet standards (was: call function for times with different types) Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2014-08-26 18:22 +0200
  Re: call function for times with different types Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2014-08-26 14:56 +0200
  Re: call function for times with different types Scott Sauyet <scott.sauyet@gmail.com> - 2014-09-02 13:39 -0700

csiph-web