• 《Javascript 语言精粹》 中 用到的一些代码 (1)


    var isNumber = function isNumber(value){
        return typeof value === 'number' && isFinite(value);
    }
    ------------------------------------------------------------------
    var i;
    var word;
    var text = "This oracle of comfort has so pleased me, "+
            "That when I am in heaven I shall desire "+
                "To see whtat this child does, "+
                "and praise my Constructor.";
    
    words = text.toLowerCase().split(/[s,.]+/);
    var count = {};
    for(i=0;i<words.length;i++){
        word = words[i];
        if(count[word])
            count[word]+=1;
        else
            count[word]=1;
    }
    
    -----------------------------------------------------------------------
    if(typeof Object.beget !== "function"){
        Object.beget = function(o){
            var F = function(){};
            F.prototype = o;
            return new F();
        }
    }
    
    -------------------------------------------------------------------------
    
    var Foo = function(string){
        this.status = string;
    };
    
    Foo.prototype.get_status = function(){
        return this.status;
    }
    var myFoo = new Foo("hello_world");
    alert(myFoo.get_status());
    -------------------------------------------------------------------------
    
    var statusObject = {
        "status":"OK"
    }
    
    var status = Foo.prototype.get_status.applay(statusObject);
  • 相关阅读:
    微信JSSDK使用指南
    安装eclipse中html/jsp/xml editor插件以及改动html页面的字体
    OpenLayers 3+Geoserver+PostGIS实现点击查询
    编程算法
    javascript闭包具体解释
    网络安全基本概念
    Android 5.1 Settings源代码简要分析
    Linq 使用注意
    父类引用指向子类对象
    CPU使用率
  • 原文地址:https://www.cnblogs.com/superzlc/p/3768359.html
Copyright © 2020-2023  润新知