Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.javascript > #12074
| From | Dr J R Stockton <reply1208@merlyn.demon.co.uk> |
|---|---|
| Newsgroups | comp.lang.javascript |
| Subject | Re: Get object name from function |
| Date | 2012-02-22 19:02 +0000 |
| Organization | Home |
| Message-ID | <tQkk9jGsuTRPFw7V@invalid.uk.co.demon.merlyn.invalid> (permalink) |
| References | <a256bb7e-3683-43d7-a9c9-086f391db492@m2g2000vbc.googlegroups.com> |
In comp.lang.javascript message <a256bb7e-3683-43d7-a9c9-086f391db492@m2
g2000vbc.googlegroups.com>, Tue, 21 Feb 2012 14:04:38, Archos
<raul.san@sent.com> posted:
>If if is passed an object with a method to a function, would be
>possible to get the name of that object from the function)
Very readily. If the argument is an Object, just access its name
property.
FuncTest(Ob) { alert(Ob.name) }
>funcTest(array.slice(4,8)) // should get: "array"
But, from that, you seem to want its identifier.
That is possible if, and AFAIR only if, the argument is a function that
has been declared in the common manner :
function IDofFunc(Fn) { // Fn is a function; return its name
var A = Fn.toString().match(/function\s+(\w+)\(/)
return A ? A[1] : "anon" }
--
(c) John Stockton, nr London, UK. ?@merlyn.demon.co.uk Turnpike v6.05.
Website <http://www.merlyn.demon.co.uk/> - w. FAQish topics, links, acronyms
PAS EXE etc. : <http://www.merlyn.demon.co.uk/programs/> - see in 00index.htm
Dates - miscdate.htm estrdate.htm js-dates.htm pas-time.htm critdate.htm etc.
Back to comp.lang.javascript | Previous | Next — Previous in thread | Find similar | Unroll thread
Get object name from function Archos <raul.san@sent.com> - 2012-02-21 14:04 -0800
Re: Get object name from function Stefan Weiss <krewecherl@gmail.com> - 2012-02-21 23:27 +0100
Re: Get object name from function Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2012-02-22 11:42 +0100
Re: Get object name from function RobG <rgqld@iinet.net.au> - 2012-02-21 18:34 -0800
Re: Get object name from function Dr J R Stockton <reply1208@merlyn.demon.co.uk> - 2012-02-22 19:02 +0000
csiph-web