GithubHelp home page GithubHelp logo

javascript's People

Contributors

donson avatar

Stargazers

 avatar

Watchers

 avatar  avatar

javascript's Issues

《编写可维护的JavaScript》读书笔记

Page88 检测

检测原始值

//检测字符串
if(typeof name === "string"){
}

//检测数字
if(typeof coutn === "number"){
}

//检测布尔值
if(typeof found === "boolean" && found){
}

//检测 undefined
if(typeof MyApp === "undefined"){
}

//检测 null
var element = document.getElementById('my_div');
if(element !== null){
}

检测在引用值

//检测日期
if(value instanceof Date){
}

//检测正则表达式
if(value instanceof RegExp){
}

//检测 Error
�if(value  instanceof Error){
} 

检测函数

var myFun = function(){};
console.log(typeof myFun === "function");

/*
  用typeof来检测函数有一个限制,在IE8和更早版本的IE浏览器中,
  检测DOM节点中的函数都会返回“object”,而不是"function"
*/
//检测 DOM 方法
if("querySelectorAll" in document){
}

检测数组

function isArray(value){
    return Object.prototype.toString.call(value) === "[object Array]";
}

检测属性

var obj = {
    count : 0
};

if("count" in obj){
}

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.