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. 奇艺iOS移动端网络优化实践 | 请求成功率优化篇 原创 Charles 爱奇艺技术

    奇艺iOS移动端网络优化实践 | 请求成功率优化篇 原创 Charles 爱奇艺技术

  2. LOJ10019生日蛋糕

    Mr.W 要制作一个体积为 N*π 的 M 层生日蛋糕,每层都是一个圆柱体. 设从下往上数第 i 蛋糕是半径为 R_i,高度为 H_i 的圆柱.当 i<M 时,要求 R_i>R_{i+1} ...

  3. Android webview 问题记录

    1. Android 7.1真机安装调试apk时报错,解析安装包失败 原因:sdk版本不支持7.1版本,需要调整minSdkVersion等参数,支持低版本 解决方法: android { compi ...

  4. SparkStreaming直连方式读取kafka数据,使用MySQL保存偏移量

    SparkStreaming直连方式读取kafka数据,使用MySQL保存偏移量 1. ScalikeJDBC 2.配置文件 3.导入依赖的jar包 4.源码测试 通过MySQL保存kafka的偏移量 ...

  5. 交换机CPU使用率高的原因

    交换机CPU的功能 1.管理已配置的软件协议,例如: – 生成树协议(STP) – 路由协议,例如OSPF和EIGRP – 热备路由协议(HSRP) – 思科发现协议(CDP) – 端口聚合协议(PA ...

  6. Java编程工具IDEA的使用

    IDEA psvm + Enter 快速构建main方法 sout + Enter 快速打印与句 Ctrl+Shift + Enter,语句完成 Ctrl+F12,可以显示当前文件的结构 Ctrl + ...

  7. CCF CSP 202012-3 文件配额

    题目背景 小 H 同学发现,他维护的存储系统经常出现有人用机器学习的训练数据把空间占满的问题,十分苦恼. 查找了一阵资料后,他想要在文件系统中开启配额限制,以便能够精确地限制大家在每个目录中最多能使用 ...

  8. 整理我的Git常见问题和命令

    整理我的Git常见问题和命令 目录 整理我的Git常见问题和命令 提交注释规范 合并分支 clone & 切换分支 支持中文路径显示 账户及密码 基于远程分支创建本地分支 提交注释规范 举例: ...

  9. jackson学习之七:常用Field注解

    欢迎访问我的GitHub https://github.com/zq2599/blog_demos 内容:所有原创文章分类汇总及配套源码,涉及Java.Docker.Kubernetes.DevOPS ...

  10. Redis-第七章节-持久化

    目录 概述 RDB AOF 如何选择持久化机制 1.概述 Redis 是内存数据库,如果不能将内存中的数据保存到磁盘中,那么一旦服务器进程退出,服务器的数据库数据也会消失,所以Redis提供了持久化的 ...