在javascript中的功能. [英] Function in javascript.

查看:71
本文介绍了在javascript中的功能.的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好;

 

我在小工具应用程序中找到了此代码,对此感到困惑,下面是代码;

I found this code in a gadget application and I feel confusing about it, below are the code;

 

setXML	= function() {
	if (!xmlHttp) {
		xmlHttp = XMLHttp();
	}
	
	if (xmlHttp) {
		fetch();
		setTimeout('setXML()', xmlRefreshRate * 1000);
	}
}

 

 

我的问题是,如何定义这样的"setxml = function()"?但与其他示例不同,我们需要设置一个这样的函数

My question is how come it can define like this "setxml = function()" but not like other example we need set a function like this

 "function functionname(){} {..." ...希望这里的任何人都可以帮助我.

 "function functionname(){}"...hope anyone here can help me in this.

 

谢谢

推荐答案

setXML = function(){};

函数setXML(){}
相等

setXML=function(){};
and
function setXML(){}
are equal

JavaScript中变量的类型可以是数字,字符串等,变量的类型也可以是函数;
换句话说,任何功能都是可变的.

Type of variable in JavaScript may be number, string, etc, and also type of variable may be function;
or in other words, any fuction is variable.

所以你可以这样做
函数aaa()
{
        alert("hello");
}
var bbb = aaa;

So you can do this
function aaa()
{
         alert("hello");
}
var bbb=aaa;

bbb();


这篇关于在javascript中的功能.的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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