代码改变世界

阅读排行榜

JavaScript Patterns 5.7 Object Constants

2014-07-01 23:01 by 小郝(Kaibo Hao), 314 阅读, 收藏,
摘要: The principle to create Object Constants is that make variables shouldn't be changed stand out using all caps and add constants as static properties to the constructor function. 阅读全文

JavaScript Patterns 4.4 Self-Defining Functions

2014-06-10 22:34 by 小郝(Kaibo Hao), 314 阅读, 收藏,
摘要: If you create a new function and assign it to the same variable that already holds another function, you’re overwriting the old function with the new one.This pattern(lazy function definition) is useful when your function has some initial preparatory work to do and it needs to do it only once. A drawback of the pattern is that any properties you’ve previously added to the original function will be lost when it redefines itself. 阅读全文

Effective C# 学习笔记(三十三) 只在更新基类时,使用new关键字

2011-07-18 12:44 by 小郝(Kaibo Hao), 314 阅读, 收藏,
摘要: 对于new关键字在修饰方法的使用我们要小心,因为它并不是像看上去那样会把父类nonVirtual的方法,转为virtual方法。 阅读全文

Effective C# 学习笔记(十八)区分值类型和引用类型

2011-07-09 23:21 by 小郝(Kaibo Hao), 314 阅读, 收藏,
摘要: 你能分清值类型和引用类型的使用场景么? 阅读全文

JavaScript Patterns 3.2 Custom Constructor Functions

2014-05-28 22:56 by 小郝(Kaibo Hao), 312 阅读, 收藏,
摘要: When you invoke the constructor function with new, the following happens inside the function: • An empty object is created and referenced by this variable, inheriting the prototype of the function. • Properties and methods are added to the object referenced by this. • The newly created object referenced by this is returned at the end implicitly (if no other object was returned explicitly). 阅读全文

JavaScript Patterns 6.3 Klass

2014-07-17 08:18 by 小郝(Kaibo Hao), 303 阅读, 收藏,
摘要: There’s a convention on how to name a method, which is to be considered the constructor of the class. Classes inherit from other classes. There’s access to the parent class (superclass) from within the child class. 阅读全文

JavaScript Patterns 4.6 Immediate Object Initialization

2014-06-12 23:58 by 小郝(Kaibo Hao), 303 阅读, 收藏,
摘要: protect the global namespace while performing the one-off initialization tasks. 阅读全文

JavaScript Patterns 2.8 Number Conversions with parseInt()

2014-05-23 12:28 by 小郝(Kaibo Hao), 298 阅读, 收藏,
摘要: This post introduces how to deal with Number Conversions with parseInt(). 阅读全文

JavaScript Patterns 6.5 Inheritance by Copying Properties

2014-07-19 12:53 by 小郝(Kaibo Hao), 296 阅读, 收藏,
摘要: This post introduces how to implement the shallow and deep copy in JavaScript. 阅读全文

JavaScript Patterns 4.10 Curry

2014-06-18 23:01 by 小郝(Kaibo Hao), 294 阅读, 收藏,
摘要: When you find yourself calling the same function and passing mostly the same parameters, then the function is probably a good candidate for currying. You can create a new function dynamically by partially applying a set of arguments to your function. The new function will keep the repeated parameters stored (so you don’t have to pass them every time) and will use them to pre-fill the full list of arguments that the original function expects. 阅读全文