更新时间:2022-12-14 19:44:09
否,除非您返回该函数,否则无法调用.
Function2是function1专用的.
您使用
function funcOne(){返回 {funcTwo:function(){//我想调用此函数//做一点事}}}
编辑:构建代码
function funcOne(){var funcTwo = function(){//私有函数//做一点事}返回 {funcTwo:funcTwo}}
现在您可以将其称为:
funcOne().funcTwo()
I want to call a function that is in another function.
example for the functions:
function funcOne() {
function funcTwo() { // i want to call to this function
//do something
}
}
I need to call to funcTwo
function, when I click on a button which is outside of these two functions
how can i do it?
No, You can't call unless you return that function.
Function2 is private to function1.
you use
function funcOne() {
return {
funcTwo :function() { // i want to call to this function
//do something
}
}
}
EDIT: Structuring code
function funcOne() {
var funcTwo = function() { // private function
//do something
}
return {
funcTwo : funcTwo
}
}
Now you can call it as:
funcOne().funcTwo()