zoukankan      html  css  js  c++  java
  • 前端错误类型

    1、SyntaxError (语法错误)

    输入不规范,或者变量命令等不规范。

    // 缺少符号
    console.log ('hello';
    // Uncaught SyntaxError: missing ) after argument list
    
    // 变量错误
    // Uncaught SyntaxError: Invalid or unexpected token
    var 1a = 'test'

    // JSON.parse 参数不合法
    // Uncaught SyntaxError: Unexpected end of JSON input
    JSON.parse('')

      

    2、ReferenceError (引用错误)

    引用不存在的变量,将一个 undefined 变量赋值的时候,

    // test 未定义,也就是未分配栈地址
    // Uncaught ReferenceError: test is not defined
    var t = test;
    

      

    3、TypeError (类型错误)

    // 类型调用错误
    // Uncaught TypeError: Object.test is not a function
    // test 未定义,应该是undefined,这里作为函数调用
    Object.test()
    
    // undefined 上面引用某一个属性
    // Uncaught TypeError: Cannot read property 'a' of undefined
    var test = undefined;
    var t = test.a;
    
    var test = {}
    var t = test.test.a;
    
    // null  上面引用某一个属性(虽然 null typeof 是对象,但是也会报错)
    // Uncaught TypeError: Cannot read property 'a' of null
    var test = null
    var t = test.a
    

      

    4、RangeError (范围越界错误)/ URIError (URI不正确) 

    // Uncaught RangeError: Invalid array length
    new Array(-1)
    
    // Uncaught URIError: URI malformed
    decodeURI('%dfd')
    

      

  • 相关阅读:
    jQuery实现仿微博发布框字数提示
    jQuery实现滚动公告练习
    jQuery实现页面搜索
    jQuery某网站品牌列表效果
    [转]windows中断与共享的连接(samba)
    rpm --rebuilddb
    【转】一个 Linux 上分析死锁的简单方法
    取消脚本进程之——后台进程
    whoami与who am i
    linux启动执行某个脚本
  • 原文地址:https://www.cnblogs.com/jiebba/p/11314383.html
Copyright © 2011-2022 走看看