<!DOCTYPE html><html lang="en"><head>    <meta charset="UTF-8">    <title>closure的自调用函数式写法</title>    <script type="text/javascript">    var a = (function(name){        var n = name; …
<!DOCTYPE html><html lang="en"><head>    <meta charset="UTF-8">    <title>closure</title>    <script type="text/javascript">    function fn(){        var n = '123';        return func…
1.单对象克隆 <!DOCTYPE html><html lang="en"><head>    <meta charset="UTF-8">    <title>singleClone</title>    <script type="text/javascript">    var clone = function(target,obj){        fo…
<!DOCTYPE html><html lang="en"><head>    <meta charset="UTF-8">    <title>prototypeInherit</title>    <script type="text/javascript">    //原型式继承:实质上就是类式继承的函数封装(但有缺陷)    function inher…
<!DOCTYPE html><html lang="en"><head>    <meta charset="UTF-8">    <title>groupInherit</title>    <script type="text/javascript">    //声明父类    function superClass(name){        this.n…
<!DOCTYPE html><html lang="en"><head>    <meta charset="UTF-8">    <title>constructorfunctionInherit</title>    <script type="text/javascript">    //声明父类    function superClass(id){  …
<!DOCTYPE html><html lang="en"><head>    <meta charset="UTF-8">    <title>classInherit</title>    <script type="text/javascript">    //声明父类    function superClass(){        this.name…
技巧点:对象方法中返回当前对象就可以链式调用了,即方法中写return this; <!DOCTYPE html><html lang="en"><head>    <meta charset="UTF-8">    <title>returnObject</title>    <script type="text/javascript">    var chec…
原理:参数适配器说白了就是给出要带入数据字段的对应字段的默认值,一旦数据字段值不足,就取默认值补足. [写法一]:直接返回 <!DOCTYPE html><html lang="en"><head>    <meta charset="UTF-8">    <title>参数适配器1</title>    <script type="text/javascript"&g…
<!DOCTYPE html><html lang="en"><head>    <meta charset="UTF-8">    <title>单例模式——在js中就是指的单个对象,可用于命名空间声明</title> </head><body>    <div id="box"></div></body><…