Top 10 JavaScript errors

javascript errors

https://rollbar.com/blog/tags/top-errors

https://rollbar.com/blog/top-10-javascript-errors/

  1. TypeError

  2. RangeError

  3. ReferenceError

  4. SyntaxError

  5. InternalError

  6. URIError

  7. Warning

  8. EvalError

JavaScript Errors

https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Errors

https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error

Uncaught TypeError: Cannot read property '...' of undefined

var foo;

foo.getName();
// Uncaught TypeError: Cannot read property 'getName' of undefined foo.name;
// Uncaught TypeError: Cannot read property 'name' of undefined

Uncaught TypeError: Cannot read property 'length' of null

var obj = null;

obj.length;
// Uncaught TypeError: Cannot read property '...' of null undefined == null;
//true
undefined === null;
//false

CORS script error

// .htaccess
// Access-Control-Allow-Origin // crossorigin="anonymous"

Uncaught TypeError: ... is not a function

var foo;

this.foo();
// Uncaught TypeError: this.foo is not a function foo();
// Uncaught TypeError: foo is not a function

this & context error

The reason is that the anonymous function being executed is in the context of the document, whereas clearBoard is defined on the window.


function clearBoard(){
alert("Cleared");
} document.addEventListener("click", function(){
console.log(`this`, this);
// this === #document
this.clearBoard();
}); window.addEventListener("click", function(){
console.log(`this`, this);
// this === Window
this.clearBoard();
});

bind

var that = this;
var self = this;
// save reference to 'this', while it's still this! document.addEventListener("click", function(){
self.clearBoard();
// that.clearBoard();
}); / /Alternatively, in the newer browsers, you can use the bind() method to pass the proper reference: document.addEventListener("click", this.clearBoard.bind(this));

Uncaught RangeError

Number.toExponential(digits) accept digits from 0 to 100

Number.toFixed(digits) accept digits from 0 to 100

Number.toPrecision(digits) accepts digits from 1 to 100.

new Array(-1);
// Uncaught RangeError: Invalid array length var num = 2; num.toExponential(-2);
// Uncaught RangeError: toExponential() argument must be between 0 and 100 at Number.toExponential // num.toFixed(101);
// Uncaught RangeError: toFixed() digits argument must be between 0 and 100 at Number.toFixed num.toPrecision(0);
// Uncaught RangeError: toPrecision() argument must be between 1 and 100 at Number.toPrecision

Number


Number.MAX_VALUE;
// 1.7976931348623157e+308 Number.MAX_VALUE + Number.MAX_VALUE;
// Infinity
Number.parseFloat(Infinity);
// Infinity Number.MIN_VALUE;
// 5e-324 Number.MAX_SAFE_INTEGER;
// 9007199254740991 Number.MIN_SAFE_INTEGER;
// -9007199254740991

function local params empty bug

function 形参,实参


var testArray= ["Test"]; function testFunction(testArray) {
for (var i = 0; i < testArray.length; i++) {
console.log(testArray[i]);
}
}
testFunction();

Uncaught TypeError: Cannot set property '...' of undefined


var foo; foo.name = foo;
// Uncaught TypeError: Cannot set property 'name' of undefined

Uncaught ReferenceError: ... is not defined


xyz;
// Uncaught ReferenceError: xyz is not defined

Errors on the world’s top 100 websites and how to avoid them

https://rollbar.com/blog/top-100-websites-errors/

HTTP error


TypeScript

  1. JavaScript that scales.
  2. TypeScript is a typed superset of JavaScript that compiles to plain JavaScript.
  3. Any browser. Any host. Any OS. Open source.

https://www.typescriptlang.org/

refs

https://rollbar.com/error-tracking/javascript/



xgqfrms 2012-2020

www.cnblogs.com 发布文章使用:只允许注册用户才可以访问!


Top 10 JavaScript errors的更多相关文章

  1. The Top 10 Javascript MVC Frameworks Reviewed

    Over the last several months I have been in a constant search for the perfect javascript MVC framewo ...

  2. Top 10 JavaScript编辑器,你在用哪个?

    对于JavaScript程序员来说,目前有很多很棒的工具可供选择.文本将会讨论10个优秀的支持JavaScript,HTML5和CSS开发,并且可以使用Markdown进行文档编写的文本编辑器.为什么 ...

  3. GitHub上最流行的Top 10 JavaScript项目

    统计出Github中所有项目的数量,几乎是不可能的,而明确指出哪些是最优秀的项目就更不可能了.如果说到JavaScript,曾经极富创新的项目(很可能)在一两个月后就会变得过时.落后.以防被淹没在大量 ...

  4. Top 10 Javascript MVC 框架

    在网上偶然看到了,几种MVC框架各有优缺点,但Backbone和Ember的呼声相对更高-大家参考一下哈- http://codebrief.com/2012/01/the-top-10-javasc ...

  5. OWASP Top 10 – 2013, 最新十大安全隐患(ASP.NET解决方法)

    OWASP(开放Web软体安全项目- Open Web Application Security Project)是一个开放社群.非营利性组织,目前全球有130个分会近万名会员,其主要目标是研议协助解 ...

  6. [转]Top 10 DTrace scripts for Mac OS X

    org link: http://dtrace.org/blogs/brendan/2011/10/10/top-10-dtrace-scripts-for-mac-os-x/ Top 10 DTra ...

  7. ASP.NET Core中的OWASP Top 10 十大风险-失效的访问控制与Session管理

    不定时更新翻译系列,此系列更新毫无时间规律,文笔菜翻译菜求各位看官老爷们轻喷,如觉得我翻译有问题请挪步原博客地址 本博文翻译自: https://dotnetcoretutorials.com/201 ...

  8. OWASP TOP 10 2017中文译文

    说明:owasp top 10其实有中文官方版本:本文是按着英文版进行翻译而成. 官方中文版:http://www.owasp.org.cn/owasp-project/OWASPTop102017v ...

  9. SQL Server: Top 10 Secrets of a SQL Server Expert

    转载自:http://technet.microsoft.com/en-us/magazine/gg299551.aspx Many companies have downsized their IT ...

随机推荐

  1. 强连通分量 与 2-SAT

    近期一直在刷这方面的题 因为没法学新知识 但又想写点什么 就水篇博文吧 引理 简单来说,在一个有向图中,若所有点之间两两互相直接可达,则将这个图成为强连通分量 强连通分量可以是某个有向图中的子图 求强 ...

  2. 【Android初级】如何实现一个具有选择功能的对话框效果(附源码)

    我们去餐厅吃饭时,服务员都会拿菜单给我们选择点什么菜.今天就分享一个具有选择功能的简易对话框,给用户展示一个选择列表.实现思路如下: 既然有选择列表,那么这个列表的内容肯定保存在某个地方 用户选择某一 ...

  3. Java 性能调优的 11 个实用技巧

    大多数开发人员认为性能优化是个比较复杂的问题,需要大量的经验和知识.是的,这并不没有错.诚然,优化应用程序以获得最好的性能并不是一件容易的事情,但这并不意味着你在没有获得这些经验和知识之前就不能做任何 ...

  4. JS 实现一个实时动态校验,将输入格式错误的显示为红色背景

    功能描述: 源码: 功能描述: 实时动态校验,如果输入的格式错误,将弹窗提示输入格式错误并将背景展示为红色. 源码: 前台: <hy:formfield name="cxfdl&quo ...

  5. springsecurity教程一

    可以看这个人的springsecurity省的自己写了 1.springsecurity学习目标 2.1 springsecurity简介 2.2 springsecurity快速入门demo 1): ...

  6. 微信支付V3 SDK Payment Spring Boot 1.0.6 发布,实现留守红包,助力抗疫

    春节将至,为防控疫情,多地政府提倡员工.外来务工者留守本地过年,并鼓励企业向员工发放"留守红包".为此,微信支付推出"春节留守红包"能力,希望可以协助有发放需求 ...

  7. Chapter Zero 0.2.3 显示适配器

    显示适配器(Video Graphics Array,VGA) 不看后悔!!深入了解显卡!!!走你! 我们常常会调试显示器的分辨率,一般对于图像的显示重点在于分辨率与颜色深度, 每个图像显示的颜色会占 ...

  8. C++ 指针 new delete int*与string

    一 指针 string和int 都可以认为是四个字节sizeof(string)==4, string是个类,它的空间在堆动态分配 二.delete 只是释放空间 三.new 数组 int size= ...

  9. 牛客网-Beautiful Land 【01背包 + 思维】

    链接:https://www.nowcoder.com/acm/contest/119/F来源:牛客网 Now HUST got a big land whose capacity is C to p ...

  10. zzuli-2259 matrix

    题目描述 在麦克雷的面前有N个数,以及一个R*C的矩阵.现在他的任务是从N个数中取出 R*C 个,并填入这个矩阵中.矩阵每一行的法值为本行最大值与最小值的差,而整个矩阵的法值为每一行的法值的最大值.现 ...