The Better Way to Debug Your JavaScript Program
Debugging JS program is not as easy as we do in Visual Studio or any other IDE. I usually us "alert()" function to add some breakpoints for debugging.
For example:
var costAdjust = $(e.container).find("input[name='CostAdjustment']").data("kendoNumericTextBox");
costAdjust.value(Number($("#extraMinTotal").html()) * Number($("#extraMinRate").html()));
costAdjust.trigger("change", { value:costAdjust.value() });
If the costAdjust didn't trigger like I expect. I will add a alert try to check if the #extraMinRate got the right value.
var costAdjust = $(e.container).find("input[name='CostAdjustment']").data("kendoNumericTextBox");
alert($("#extraMinRate").html());
costAdjust.value(Number($("#extraMinTotal").html()) * Number($("#extraMinRate").html()));
costAdjust.trigger("change", { value:costAdjust.value() });
But in this way it will stop your page coding flow and it can't show all the detail if you try to see object's value. Like this:
var costAdjust = $(e.container).find("input[name='CostAdjustment']").data("kendoNumericTextBox");
alert($("#extraMinRate"));
costAdjust.value(Number($("#extraMinTotal").html()) * Number($("#extraMinRate").html()));
costAdjust.trigger("change", { value:costAdjust.value() });
This time alert will only showing "Object" without any detail:

The better way to show the object detail is using "console.log()" instead of alert.
var costAdjust = $(e.container).find("input[name='CostAdjustment']").data("kendoNumericTextBox");
console.log($("#extraMinRate"));
costAdjust.value(Number($("#extraMinTotal").html()) * Number($("#extraMinRate").html()));
costAdjust.trigger("change", { value:costAdjust.value() });
You should check your output using chrome browser inspect function (Ctrl + Shift + I). At he Console tab, you will see the object detail.

You can click the little trianggle to find more details of this object. That allows you to trace your code data easierly and your page flow will not be stoped.
<END>
The Better Way to Debug Your JavaScript Program的更多相关文章
- Why we made vorlon.js and how to use it to debug your JavaScript remotely
Vorlon.js is powered by node.JS, socket.io, and late-night coffee. I would like to share with you wh ...
- Use GDB to debug a C++ program called from a shell script
解决了我一个大问题!!! http://stackoverflow.com/questions/5048112/use-gdb-to-debug-a-c-program-called-from-a-s ...
- gdb/valgrind/coredump to debug c/cpp program
gdb/valgrind/coredump 调试 1.gdb 调试 while/for 循环 ①如果在调试 while/for的时候,可以用until xxx(其中,xxx代表 行号)直接跳转到循环后 ...
- Using DTrace to Profile and Debug A C++ Program
http://www.oracle.com/technetwork/server-storage/solaris/dtrace-cc-138561.html
- Best JavaScript Tools for Developers
JavaScript solves multiple purposes; it helps you to create interactive websites, web applications, ...
- 【repost】JavaScript Scoping and Hoisting
JavaScript Scoping and Hoisting Do you know what value will be alerted if the following is executed ...
- VS2008 Debug与Release的本质区别(转)
如何设置:工具栏“生成”→“配置管理器”→“活动解决方案配置” 对于VS2008的初次使用者来说,常会遇到的编译问题时,Debug版本运行正常,但在Release版本则不稳定或无法运行.以下是对Deb ...
- Debug与Release的区别
Debug版本包括调试信息,所以要比Release版本大很多(可能大数百K至数M).至于是否需要DLL支持,主要看你采用的编译选项.如果是基于ATL的,则Debug和Release版本对DLL的要求差 ...
- [转]Debug 和 Release 编译方式的区别
本文主要包含如下内容: 1. Debug 和 Release 编译方式的本质区别 2. 哪些情况下 Release 版会出错 3. 怎样“调试” Release 版的程序 Debug 和 Releas ...
随机推荐
- vs2010 更新jQuery智能提示包
vs2010 更新jQuery只能提示包时,可以直接在NuGet中更新 jquery-2.1.0-vsdoc.js jquery-2.1.0.js jquery-2.1.0.min.js jquery ...
- bzoj 2761 [JLOI2011]不重复数字(哈希表)
2761: [JLOI2011]不重复数字 Time Limit: 10 Sec Memory Limit: 128 MBSubmit: 3210 Solved: 1186[Submit][Sta ...
- bat坐拥大数据。数据挖掘/大数据给他们带来什么。
阿里巴巴CTO即阿里云负责人王坚博士说过一句话:云计算和大数据,你们都理解错了. 实际上,对于大数据究竟是什么业界并无共识.大数据并不是什么新鲜事物.信息革命带来的除了信息的更高效地生产.流通和消 ...
- noip2011 公交观光
描述 风景迷人的小城Y市,拥有n个美丽的景点.由于慕名而来的游客越来越多,Y市特意安排了一辆观光公交车,为游客提供更便捷的交通服务.观光公交车在第0分钟出现在1号景点,随后依次前往2.3.4……n号景 ...
- sublime text 2 运行 python时返回EOFError: EOF when reading a line错误
其主要原因是sublime text 2中python没有与 stdin(标准输入)连接所致,解决方法也很简单,那就是安装sublimeREPL插件,然后 Tools->sublimerepl- ...
- phonegap与google analytics整合
用phonegap开发的app接近尾声,需要整一个谷歌分析进去. 1.首先申请一个GA帐号,在“what would you like to track”下选择APP
- Java 字符转码之UTF-8转为GBK/GB2312
java跟python类似的做法,在java中字符串的编码是java修改过的一种Unicode编码,所以看到java中的字符串,心理要默念这个东西是java修改过的一种Unicode编码的编码. pa ...
- Gof-23种设计模式名称列表
工欲善其事,必先利其器. 在真正使用设计模式之前,必须知道各个设计模式对应的场景.设计模式是针对某种固定的场景下产生的固定解决方案.只有明确的场景,才会有明确的设计方式和方法. 设计模式全集: Abs ...
- mysql 配置参数
mysql JDBC Driver 常用的有两个,一个是gjt(Giant Java Tree)组织提供的mysql驱动,其JDBC Driver名称(JAVA类名)为:org.gjt.mm.mysq ...
- 关于wordpress在修改固定链接后,总显示Not Found的问题
参考来源: http://chinablog.blog.51cto.com/276793/280278 一.问题背景 使用wordpress搭建网站,为了让文章URL看起来漂亮一点,wordpress ...