摘要:
1.什么是 prototypeprototype 对于 JavaScript 的 意义重大,prototype 不仅仅是一种管理对象继承的机制,更是一种出色的设计思想在现实生活中,我们常常说,某个东西是以另一个东西为原型创作的。这两个东西可以是同一个类型, 也可以是不同类型。习语“照猫画虎”,这里的猫就是原型,而虎就是类型,用 JavaScript 的 prototype 来 表示就是“虎.prototype =某只猫”或者“虎.prototype= new 猫()”eg:function ClassA(){...... }ClassA.prototype = new Object(); fu 阅读全文
摘要:
using System;using System.Collections.Generic;using System.Linq;using System.Text;namespace ReflectionTest{ public class Employee { public string Name { get; set; } public int Age { get; set; } }}using System;using System.Collections.Generic;using System.Linq;using System.Text... 阅读全文
摘要:
bad code// BEFORE: 5 globals// Warning: antipattern// constructorsfunction Parent() {}function Child() {}// a variablevar some_var = 1;// some objectsvar module1 = {};module1.data = {a: 1, b: 2};var module2 = {};good code// AFTER: 1 global// global objectvar MYAPP = {};// constructorsMYAPP.Parent = 阅读全文
摘要:
This pattern is useful when your function has some initial preparatory work to do andit needs to do it only once.In such cases, the selfdefining function can update its own implementation.eg:var selfFunc = function () { console.log("First Initialization!"); selfFunc = function () { ... 阅读全文
摘要:
The caching options available in ASP.NET MVC applications don’t come from the ASP.NET MVC Framework, but from the core ASP.NET Framework.1. Request-Scoped CachingEvery ASP.NET request begins with the ASP.NET Framework creating a new instanceof the System.Web.HttpContext object to act as the central 阅读全文
摘要:
overriding the default options with user-supplied options and the jQuery extend() methodeg:$.fn.pulse = function (options) { // Merge passed options with defaults var opts = $.extend({}, $.fn.pulse.defaults, options); return this.each(function () { // Pulse for (var i = 0; i <... 阅读全文
摘要:
1. How do you write a plugin in jQuery?You can extend the existing jQuery object by writing either methods or functions.1) Writing a custom jQuery methodjQuery methods are defined by extending the jQuery.fn object with your method name.$.fn.extend({ //Only Test MasterTest: { alertTest: ... 阅读全文
摘要:
1. Base2. Layout3. Module4. State5. Theme1) Base rulesBase rules are the defaults.eg:html, body, form { margin: 0; padding: 0; }input[type=text] { border: 1px solid #999; }a { color: #039; }a:hover { color: #03C; }2) Layout rulesdivide the page into sections. Layouts hold one ormore modules together 阅读全文
摘要:
1. 动态添加对象的属性和方法// start with an empty objectvar dog = {};// add one property dog.name = "Benji";// now add a method dog.getName = function () { return dog.name; };2. 一次性创建对象var dog = { name: "Benji", getName: function () { return this.name; }};3. 使用内建的构造函数// one way -- using a li 阅读全文
摘要:
jQuery UI Widget - Default functionality color me color me color me Toggle disabled option Go black 运行结果: 阅读全文