写在前面:人生止步于梦想,取法乎上,得乎其中

我日你妈,哥写了很多的文字没保存然后就没了,真的要哭了。
下面只能简单回忆一下了。

  • 第一章 25页 js是区分大小写的。
  • 40页 js转义字符
  • 50页 显式类型转换
  • 77页 字符串比较是区分大小写的,所有的大写的ascii字符都小于小写的。
  • 104页 for/in 语句
  • 106页 跳转和标签语句
  • 120页 对象创建的三种办法
  • 125页 对象的继承,用到了如下的继承函数:
// inherit() returns a newly created object that inherits properties from the
// prototype object p.  It uses the ECMAScript 5 function Object.create() if
// it is defined, and otherwise falls back to an older technique.
function inherit(p) {
    if (p == null) throw TypeError(); // p must be a non-null object
    if (Object.create)                // If Object.create() is defined...
        return Object.create(p);      //    then just use it.
    var t = typeof p;                 // Otherwise do some more type checking
    if (t !== "object" && t !== "function") throw TypeError();
    function f() {};                  // Define a dummy constructor function.
    f.prototype = p;                  // Set its prototype property to p.
    return new f();                   // Use f() to create an "heir" of p.
}

例如: 
var p = inherit(O);
  • 127页 属性删除

  • 129页 属性枚举 但是注意从原型中取到的属性是默认为false的:

    var app=Object.create({1:"233","2":"344"});
    app.x=1;
    var m=app.propertyIsEnumerable("x");  //True
    var m2=app.propertyIsEnumerable("1");  //false
    var n=app.hasOwnProperty('1');   //false
    var n2=app.hasOwnProperty('x');   //true
  • 关于getter和setter的属性自己可以通过另外自己的一篇文章来学习。

  • 关于属性的特性,我们可以有一个比getter和setter更好的办法来定义属性的特性,就是用直接定义属性的特性来做。关于属性自己有另外一个网站的资源可以参考:https://msdn.microsoft.com/zh-cn/library/dd548687
    当然自己在这里给出一个函数可以复制属性的特性的:

/*
 * Add a nonenumerable extend() method to Object.prototype.
 * This method extends the object on which it is called by copying properties
 * from the object passed as its argument.  All property attributes are
 * copied, not just the property value.  All own properties (even non-
 * enumerable ones) of the argument object are copied unless a property
 * with the same name already exists in the target object.
 */
Object.defineProperty(Object.prototype,
    "extend",                  // Define Object.prototype.extend
    {
        writable: true,
        enumerable: false,     // Make it nonenumerable
        configurable: true,
        value: function(o) {   // Its value is this function
            // Get all own props, even nonenumerable ones
            var names = Object.getOwnPropertyNames(o);
            // Loop through them
            for(var i = 0; i < names.length; i++) {
                // Skip props already in this object
                if (names[i] in this) continue;
                // Get property description from o
                var desc = Object.getOwnPropertyDescriptor(o,names[i]);
                // Use it to create property on this
                Object.defineProperty(this, names[i], desc);
            }
        }
    });
  • 148页 数组的长度改变,截断,添加,删除,和遍历。
  • 152页 数组的方法:
    • join:可以把数组连接成字符串并且用自己选择的标记比如逗号进行分割。
    • reverse:翻转,把数组翻转过来。
    • sort:排序,可以自己指定一个排序的函数。
    • concat:链接,可以作为一个方法进行调用。
    • slice:用于截取数组的片段。
    • splice:用于在数组中插入或者删除元素,和上一个差不多,返回的是被删除的元素。
    • push和pop:在结尾进行添加或者删除。
    • unshift和shift:在开头进行添加或者删除。
    • tostring和tolocalstring:将数组元素转化成字符串。
    • foreach:对于每个元素执行一个函数。
    • map:将数组一一映射到另外的一个数组里面。
    • filter:筛选数组里的一些元素。
    • every和some:对数组中的元素进行处理,所有/部分元素满足某一个条件的话就返回真。
    • reduce和reduceright:前一个是从前往后,后一个是从后往前进行处理。
  • 167页 直接调用一次函数。
  • 函数可以被嵌套在其他函数里面只要函数被定义了的话。
  • 172页 关于call 和apply自己通过另外一篇文章已经把详细的参考写了下来。
  • 181页 作为命名空间的函数
  • 闭包简单地说就是指的函数词法的作用域。
  • 188页 函数的属性和方法:这里重点介绍几个
    • 函数的length属性:返回函数传入实参的个数
    • 函数绑定:bind 函数绑定到某一个对象,再次调用的时候就会当作这个对象的方法进行调用。绑定到某一个对象,具体的方法有几种,自己在191页都圈了出来。
    • 函数式编程的相关东西自己在这里就不多解释了吧,网上也有很多关于memorize什么的讲解…有用的时候再说。
posted on 2015-04-21 21:30  虽然如此  阅读(218)  评论(0编辑  收藏  举报