如何列出所有var的语句? [英] How to list the statement of all var ?

查看:72
本文介绍了如何列出所有var的语句?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,


和2005年结束快乐!


嗯,我想获取所有JavaScript var语句的列表,

使用for ... in perharps?


这是我最近的测试,但问题是管理层

这些: - (((我必须声明并使用所有变量)有这个计划:


v [''name'']


Thanx所有建议!


================================================ == ======================

< html>

< head>

< title> for ... in(var)< / title>

< / head>

< body>

< script type =" text / javascript">

<! -

var v = new Array();

v [''titi''] ="" ;;

v [''bleah''] =''toto'';

v [ ''toto''] =''bibi'';

v [''tutu''] = 109;

v [''annonce_fr''] =" Bonne f& ecirc; tes de fin d''ann& eacute; e!" ;;

v [''annonce_en''] ="新年快乐,这是2005年年底。 ..

Hello 2006 !!&;;

函数print_all(){

for(var i in window.v){

v [ '' 蒂蒂 ''] =(typeof运算(window.v [I])=="串QUOT)?" ''":"" ;;

document.write(i +" =" + v [''titi''] +

"< ; span style =''color:blue; font-weight:bold;''>" + window.v [i] +"< / span>"

+

v [''titi''] +"< br> \ n");

}

}

print_all();

document.write("< hr> v [''tutu''] + 2 =" +(v [''tutu''] + 2) );

// - >

< / script>

< / body>

< / html>

===================================== ============= ======================

Thierry

和来自法国的问候,

http://www.google.com/maps?ll=45.128...5925,0.013087&

t = k& hl = fr>


PS:对不起我说的英语不好:-(

解决方案




Thierry Loiseau写道:

好吧,我想获取所有JavaScript var语句的列表,
With for for for ...在perharps?

这是我最近在这里的测试,但问题是管理这些: - (((我必须用这个方案声明和使用所有变量:

v [''name'']




var语句声明一个变量(或更多),可能另外

初始化变量例如

var varName;



var varName =''Kibology'';


v [''name'']是属性访问,但显然没有var语句。


语言本身没有Code对象模型

允许您的脚本代码以结构化的方式访问代码本身

,您可以在其中查找某种类型的语句或语句。


但用var语句声明的全局变量将成为全局对象的属性(这是

客户端浏览器中的窗口对象)如果那些属性不是用内部属性DontEnum标记的
,那么使用for..in语句枚举对象的属性和对象的属性可以是

。由于var语句

定义没有指定内部DontEnum属性应该为声明的变量设置为b / b
实现应该将所有声明的变量枚举为

for..in。

-


Martin Honnen
http://JavaScript.FAQTs.com/

Martin Honnen< ma ******* @ yahoo.de>写道:

var语句声明一个变量(或更多),并可能另外
初始化变量,例如




我很害羞声明我的第一个消息是不是很好: - ((

法语,Etat?


Thierry





Thierry Loiseau写道:

Martin Honnen< ma ******* @ yahoo。 de>写道:

var语句声明一个变量(或更多)并可能另外
初始化变量,例如


$ b在我的第一条消息中,$ b我很害羞而且声明并不顺利: - ((
法语,Etat?




抱歉,我不能帮忙,有一个法国小组fr.comp.lang.javascript为

,据我所知,法语是主要语言,发布和阅读

可能会有更多的成功。

谷歌在这里:

< http://groups.google.com/group/fr.comp .lang.javascript?hl = zh>

嗯,我看到你已经在那里发帖了,如果这真的没有帮助你和

想在这里发帖,然后考虑用两种语言发帖子,

英语和法语,在这里,这可能会增加你的机会

这里有人明白你在看什么因为你可能有

有人在这里读的是一个流利的(足够的)法语。


-


Martin Honnen
http://JavaScript.FAQTs.com/


Hello all,

and Happy end year 2005 !

Well, I would like to obtain a list of all JavaScript var statement,
With "for...in" perharps ?

That is bellow my recent test here, but the problem is to management
theses :-((( I must to declare and use all variable with this scheme :

v[''name'']

Thanx for all suggestion !

================================================== ======================
<html>
<head>
<title>for...in (var)</title>
</head>
<body>
<script type="text/javascript">
<!--
var v=new Array();
v[''titi'']="";
v[''bleah'']=''toto'';
v[''toto'']=''bibi'';
v[''tutu'']=109;
v[''annonce_fr'']="Bonne f&ecirc;tes de fin d''ann&eacute;e !";
v[''annonce_en'']="Happy new year, this is the end of the year 2005...
Hello 2006 !!";
function print_all() {
for (var i in window.v) {
v[''titi'']=(typeof(window.v[i])=="string")?" '' ":"";
document.write(i + " = " + v[''titi''] +
"<span style=''color: blue; font-weight:bold;''>"+window.v[i]+"</span>"
+
v[''titi''] + "<br>\n");
}
}
print_all();
document.write("<hr> v[''tutu'']+2 = "+(v[''tutu'']+2));
// -->
</script>
</body>
</html>
================================================== ======================

Thierry
and best regards from France,

<http://www.google.com/maps?ll=45.128...5925,0.013087&
t=k&hl=fr>

PS : sorry for my bad english spoken :-(

解决方案



Thierry Loiseau wrote:

Well, I would like to obtain a list of all JavaScript var statement,
With "for...in" perharps ?

That is bellow my recent test here, but the problem is to management
theses :-((( I must to declare and use all variable with this scheme :

v[''name'']



The var statement declares a variable (or more) and might additionally
initialize variables e.g.
var varName;
or
var varName = ''Kibology'';

v[''name''] is a property access but obviously no var statement.

The language itself does not have a "Code object model" which would
allow your script code to access the code itself in a structured way
where you could look for statements or statements of a certain type.

But global variables declared with the var statement will become
properties of the global object (which is the window object in
client-side browser script) and properties of an object can be
enumerated using the for..in statement if those properties are not
marked with the internal attribute DontEnum. As the var statement
definition does not specify that that internal DontEnum attribute should
be set for declared variables being created as properties an
implementation should make all those declared variables enumerable with
for..in.
--

Martin Honnen
http://JavaScript.FAQTs.com/


Martin Honnen <ma*******@yahoo.de> wrote:

The var statement declares a variable (or more) and might additionally
initialize variables e.g.



I''m shure "statement" is no well come in my first message :-(((
In french, "Etat" ?

Thierry




Thierry Loiseau wrote:

Martin Honnen <ma*******@yahoo.de> wrote:

The var statement declares a variable (or more) and might additionally
initialize variables e.g.


I''m shure "statement" is no well come in my first message :-(((
In french, "Etat" ?



Sorry, I can''t help, there is a French group fr.comp.lang.javascript as
far as I know where French is the main language, posting and reading
there might be more successful for you.
Google has it here:
<http://groups.google.com/group/fr.comp.lang.javascript?hl=en>
Hmm, I see you already post there, if that really does not help and you
want to post here then consider making a post with two languages,
English and French, here, that might then increase your chances that
someone here understands what you are looking for as you might have
someone read here who is fluent (enough) in French.

--

Martin Honnen
http://JavaScript.FAQTs.com/


这篇关于如何列出所有var的语句?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆