闭包函数 闭包函数通常作为函数中的函数使用。 匿名函数 匿名函数通常作为回调函数的参数使用。 ...
分类:
Web程序 时间:
2020-05-19 15:05:13
阅读次数:
52
当函数可以记住并访问所在的词法作用域时,就产生了闭包,即使函数是当前词法作用域之外执行。 function foo() { var a = 2; function bar() { console.log(a); // 2 } bar(); } foo(); function foo() { var ...
分类:
编程语言 时间:
2020-05-16 12:47:30
阅读次数:
60
1.实例代码 a.预测球队比赛结果代码 def GameOver(a,b): if a>=10 and b>=10: if abs(a-b)==2: return True if a<10 or b<10: if a==11 or b==11: return True else: return Fa ...
分类:
其他好文 时间:
2020-05-13 20:20:42
阅读次数:
86
def foo(): print("foo") def bar(func):#func是一个指针 func() print(id(foo)) print(set)#set是一个类 print(set())#加上()后set是一个实例 bar(foo) #修饰器的好处,方便添加日志 #添加日志的土方法 ...
分类:
其他好文 时间:
2020-05-13 09:58:57
阅读次数:
60
前端同学经常忽视的一个 JavaScript 面试题 作者:Wscats 链接:https://github.com/Wscats/articles/issues/85 题目 function Foo() { getName = function () { alert (1); }; return ...
分类:
Web程序 时间:
2020-05-12 12:08:35
阅读次数:
66
```C# using System; using UnityEngine; public class Foo:MonoBehaviour{ private void Awake(){ Debug.Log("Foo.Awake();"); } private void OnEnable(){ Deb... ...
分类:
编程语言 时间:
2020-05-11 19:03:50
阅读次数:
157
一个静态属性property本质就是实现了get,set,delete三种方法 class Foo: @property def AAA(self): print('get的时候运行我啊') @AAA.setter def AAA(self,value): print('set的时候运行我啊') @ ...
分类:
其他好文 时间:
2020-05-11 18:37:59
阅读次数:
48
给定两个字符串,判断其是否是同构的。何为同构,即字符串中每个字符都是单一映射的。Input: s = "egg", t = "add"Output: true Input: s = "foo", t = "bar"Output: false 思路:设置两个哈希字典,一个保存s到t的映射,另一个保存t ...
分类:
其他好文 时间:
2020-05-11 18:33:09
阅读次数:
46
LSH:找到某个变量的值,如果查找的目的是对变量进行赋值,就会使用LSH查找。 RSH:找到变量的容器,如果查找的目的是获取变量的值,就会使用RSH查找。 function foo(a){ console.log(a) } foo(2) // 2 对foo函数的调用执行了RSH查找,还有一个隐式的a ...
分类:
其他好文 时间:
2020-05-11 01:33:13
阅读次数:
102
__iter__()将对象转换为可迭代对象,__next__()返回实现迭代 #_*_coding:utf-8_*_ __author__ = 'Linhaifeng' class Foo: def __init__(self,x): self.x=x def __iter__(self): ret ...
分类:
其他好文 时间:
2020-05-10 19:32:08
阅读次数:
63