实例1

functionnewCounter()locali=0--方法里的i变量不会被销毁returnfunction()--anonymousfunctioni=i+1returniendendc1=newCounter()print(c1())-->1print(c1())-->2


实例2


functionmyPower(x)returnfunction(y)returny^xendendpower2=myPower(2)--power2不单单拥有了方法myPower,并且拥有了参数2power3=myPower(3)print(power2(4))--4的2次方print(power3(5))--5的3次方