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


Groups > comp.lang.javascript > #16925

Re: Built-in native method

From Cezary Tomczyk <cezary.tomczyk@gmail.com>
Newsgroups comp.lang.javascript
Subject Re: Built-in native method
Date 2012-10-28 17:49 +0100
Organization Aioe.org NNTP Server
Message-ID <k6jnnq$fro$1@speranza.aioe.org> (permalink)
References (1 earlier) <67583587.7BbXikoxoM@PointedEars.de> <k69jek$r9i$1@speranza.aioe.org> <3102322.j8kCu7WbkW@PointedEars.de> <k6jgm5$snj$1@speranza.aioe.org> <8635315.16DEVHx3j1@PointedEars.de>

Show all headers | View raw


W dniu 2012-10-28 17:12, Thomas 'PointedEars' Lahn pisze:
> Cezary Tomczyk wrote:
>
>> W dniu 2012-10-25 00:03, Thomas 'PointedEars' Lahn pisze:
>> [...]
>>>     if (String.prototype.propertyIsEnumerable("trim"))
>>
>> Quick results from Google Chrome 22.0.1229.94 console.
>
> Unreadable.  What is your input, what V8's output?  Which OS and platform?

OS: Windows 7
Platform: Win32

Let me do in that way:

ID - Input data in Google Chrome console
R - result in console

ID:   String.prototype.propertyIsEnumerable("trim")
R:    false

ID:   String(String.prototype.trim);
R:    "function trim() { [native code] }"

ID:   String.prototype.trim = function(){ alert('test'); return false; };
R:    function (){ alert('test'); return false; }

ID:   String.prototype.trim
R:    function (){ alert('test'); return false; }

ID:   String(String.prototype.trim);
R:    "function (){ alert('test'); return false; }"

ID:   String.prototype.propertyIsEnumerable("trim")
R:    false

Better?

>> In both of cases means that object can not be enumerated by a for[...]in
>> loop. And as I understand it correctly this doesn't help with determine
>> if method is really built-in or not.
>
> Possible; whether property attributes are retained is implementation-
> dependent.  But now that you know that *you* can overwrite
> String.prototype.trim(), a solution to your problem should present itself.

Oh, well. Yes, I can overwrite. This is always possible. Then there is 
only hope that 3-rd party external library will correctly parse results 
from my custom method. But this is easy to verify, I know.

-- 
Cezary Tomczyk
http://www.ctomczyk.pl/

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


Thread

Built-in native method Cezary Tomczyk <cezary.tomczyk@gmail.com> - 2012-10-19 22:07 +0200
  Re: Built-in native method JJ <jaejunks_at@_googlemail_dot._com> - 2012-10-21 06:44 +0000
    Re: Built-in native method Cezary Tomczyk <cezary.tomczyk@gmail.com> - 2012-10-21 18:46 +0200
    Re: Built-in native method Cezary Tomczyk <cezary.tomczyk@gmail.com> - 2012-10-21 19:37 +0200
      Re: Built-in native method Andreas Bergmaier <andber93@web.de> - 2012-10-22 15:47 +0200
        Re: Built-in native method Cezary Tomczyk <cezary.tomczyk@gmail.com> - 2012-10-22 18:00 +0200
          Re: Built-in native method Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2012-10-24 02:17 +0100
            Re: Built-in native method Cezary Tomczyk <cezary.tomczyk@gmail.com> - 2012-10-24 22:17 +0200
              Re: Built-in native method Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2012-10-25 00:32 +0200
  Re: Built-in native method Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2012-10-24 02:15 +0100
    Re: Built-in native method Cezary Tomczyk <cezary.tomczyk@gmail.com> - 2012-10-24 22:35 +0200
      Re: Built-in native method Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2012-10-25 00:03 +0200
        Re: Built-in native method Asen Bozhilov <asen.bozhilov@gmail.com> - 2012-10-26 03:58 -0700
          Re: Built-in native method RobG <rgqld@iinet.net.au> - 2012-10-29 16:39 -0700
        Re: Built-in native method Cezary Tomczyk <cezary.tomczyk@gmail.com> - 2012-10-28 15:32 +0100
          Re: Built-in native method Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2012-10-28 17:05 +0100
            Re: Built-in native method Cezary Tomczyk <cezary.tomczyk@gmail.com> - 2012-10-28 18:39 +0100
              Re: Built-in native method Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2012-10-28 20:10 +0100
                Re: Built-in native method Cezary Tomczyk <cezary.tomczyk@gmail.com> - 2012-10-28 20:23 +0100
                Re: Built-in native method Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2012-10-28 21:23 +0100
                Re: Built-in native method Cezary Tomczyk <cezary.tomczyk@gmail.com> - 2012-10-28 22:03 +0100
        Re: Built-in native method Cezary Tomczyk <cezary.tomczyk@gmail.com> - 2012-10-28 15:49 +0100
          Re: Built-in native method Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2012-10-28 17:12 +0100
            Re: Built-in native method Cezary Tomczyk <cezary.tomczyk@gmail.com> - 2012-10-28 17:49 +0100
              Re: Built-in native method Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2012-10-28 18:07 +0100
                Re: Built-in native method Cezary Tomczyk <cezary.tomczyk@gmail.com> - 2012-10-28 19:22 +0100
                Re: Built-in native method Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2012-10-28 19:53 +0100

csiph-web