Sure, you can do this, but in general I would avoid adding functions to
prototypes of built-in types.

On Wed, Sep 22, 2010 at 9:51 AM, Martin <[email protected]> wrote:

> Just found this:
> http://www.movable-type.co.uk/scripts/latlong-convert-coords.html
>
> Number.prototype.toRad = function() {  // convert degrees to radians
>  return this * Math.PI / 180;
> };
>
> Martin.
>
>
> On 22 Sep, 00:49, Martin <[email protected]> wrote:
> > From the documentation i'd say that 'number' simply means number as a
> > primitive type not that number is an object defined by the API.
> >
> > So you want to add new methods to the javascript Number class:
> http://www.google.co.uk/search?x=59&y=32&q=javascript+number+prototyp...
> >
> > Martin.
> >
> > On 21 Sep, 22:52, Jingyuan <[email protected]> wrote:
> >
> > > Hi,
> >
> > > In API v3, LatLng.lat() Returns the latitude in degrees, whose type is
> > > 'number'
> >
> > > I want to make some extension like this:
> > >     number.prototype.toRad = function { ... }
> > > So that I can convert degree to rad directly by calling toRad()
> > > method.
> >
> > > I wonder where is the 'number' defined in Maps API v3.
> >
> > > Thanks!
> > > Jingyuan
>
> --
> You received this message because you are subscribed to the Google Groups
> "Google Maps JavaScript API v3" group.
> To post to this group, send email to
> [email protected].
> To unsubscribe from this group, send email to
> [email protected]<google-maps-js-api-v3%[email protected]>
> .
> For more options, visit this group at
> http://groups.google.com/group/google-maps-js-api-v3?hl=en.
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Google Maps JavaScript API v3" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/google-maps-js-api-v3?hl=en.

Reply via email to