Q:

Polymorphism in JavaScript to have different constructors

I am new to JavaScript, I have been working in Java and C++, there we have polymorphism for Constructors; Example:
class Car
{
     Car()
     {
         ....
         //body
         ....
     }
     Car(int speed, string body_type)
     {
          ....
          //body
          ....
     }
};

I was trying object oriented programming in JavaScript using the same concept.  I wrote this code:
<html>
<head>
    <script type="text/javascript">
    function bike()
    {
        this.bike_type="scooter";
    this.bike_bidy="metal";
        this.bike_speed=40;
        document.write('bike instantiated with type:'+this.bike_type);  
    }
    function bike(type, body, speed)
    {
        this.bike_type=type;
        this.bike_bidy=body;
        this.bike_speed=speed;
        document.write('bike instantiated with type:'+type);    
    }
    bike1 = new bike("harley","metal",120);
    bike2 = new bike();
    document.write(bike1.bike_type);
    document.write(bike2.bike_speed);
</script>
</head>
<body>
</body>
</html>

But here, I get instance only for the bike() function/class not for bike(type, body, speed).  When I tried this:
<html>
<head>
    <script type="text/javascript">
    function bike(type, body, speed)
    {
        this.bike_type=type;
        this.bike_bidy=body;
        this.bike_speed=speed;
        document.write('bike instantiated with type:'+type);    
    }
    function bike()
    {
        this.bike_type="scooter";
    this.bike_bidy="metal";
        this.bike_speed=40;
        document.write('bike instantiated with type:'+this.bike_type);  
    }
    bike1 = new bike("harley","metal",120);
    bike2 = new bike();
    document.write(bike1.bike_type);
    document.write(bike2.bike_speed);
</script>
</head>
<body>
</body>
</html>

Then I get, instance for function bike(type, body, speed) not for bike().  I understood that it is only taking the 1st definition.  And the way I am doing is not allowed. 
How can I make a polymorphic constructor in JavaScript?  Is it possible? 

A:

In Javascript:

a global function can only be defined once
function arguments are optional
function arguments are available through a pseudo-array called arguments (see the docs). 

So you can do something like this:
function bike(type, body, speed)
{
    if (arguments.length >= 3) {
        this.bike_type = type;
        this.bike_body = body;
        this.bike_speed = speed;
        document.write('bike instantiated with type:'+type);    
    } else {
        this.bike_type = "scooter";
        this.bike_body = "metal";
        this.bike_speed = 40;
        document.write('bike instantiated with type:'+this.bike_type);  
    }
}

A:

No, it's not possible.  In both cases, the second function definition overwrites the first. 
You have to examine your arguments from within your function, and alter your functions behaviour accordingly. 
In your case, you can simply use defaults if none were given:
function bike(type, body, speed)
{
    this.bike_type = type || "scooter";
    this.bike_bidy = body || "metal";
    this.bike_speed = speed || 40;
}

It is also very common to use a single options argument, something like bike({body: "carbon fiber"}), allowing you to omit leading parameters without having to specify undefined in their place. 
function bike(options)
{
    this.bike_type = options.type || "scooter";
    // ...
}

