有可能有一个Javascript变量有两个或更多的功能里面? [英] Is it possible to have a Javascript variable to have two or more functions inside?
本文介绍了有可能有一个Javascript变量有两个或更多的功能里面?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有以下Javascript代码:
var Lab = {
minseat:function(){
var seat = 10;
返回座位;
}
maxseat:function(){
var seat = 50;
返回座位;
}
}
所以,当我需要得到这个值,我简单地调用下面的代码:
$ $ $ $ $ codeonsole.log(Min Seat:+ Lab.minseat()) ;
console.log(Max Seat:+ Lab.maxseat());
但是,它似乎不起作用。所以,我可以知道是否有可能有一个Javascript变量有两个或更多的函数内部? 你忘了一个第一个函数之后的逗号:
var Lab = {
minseat:function(){
var seat = 10;
返回座位;
},
maxseat:function(){
var seat = 50;
返回座位;
}
}
I have the following Javascript code:
var Lab = {
minseat: function(){
var seat = 10;
return seat;
}
maxseat: function(){
var seat = 50;
return seat;
}
}
So, when I need to get the value, I simply call the following code:
console.log(" Min Seat: " + Lab.minseat());
console.log(" Max Seat: " + Lab.maxseat());
However, it seems it is not working. So, may I know if it is possible to have a Javascript variable to have two or more functions inside?
解决方案
You forgot a comma after the first function:
var Lab = {
minseat: function(){
var seat = 10;
return seat;
},
maxseat: function(){
var seat = 50;
return seat;
}
}
这篇关于有可能有一个Javascript变量有两个或更多的功能里面?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文