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 ...
随机推荐
- 解决Subclipse1.6在64位JDK下不可用的问题
Failed to load JavaHL Library. These are the errors that were encountered: 需要下载SVNKit Adapter Sub ...
- Qt学习之路(2)------Qt中的字符串类
QString QString的一些基本用法 basic.cpp #include <QTextStream> int main(void) { QTextStream out(stdou ...
- 《C程序设计语言现代方法》第5章 选择语句
关系运算符的优先级低于算术运算符,关系运算符都是左结合的. 判等运算符的优先级低于关系运算符,判等运算符也是左结合的. 逻辑运算符将任何非零值操作数作为真值来处理,同时将任何零值操作数作为假值来处理. ...
- [LeetCode] 234. Palindrome Linked List 解题思路
Given a singly linked list, determine if it is a palindrome. Follow up:Could you do it in O(n) time ...
- Spock Proxy
Spock Proxy undefined 服务网关_百度搜索 undefined 8月2日,深圳 | DockOne技术沙龙开始报名啦 - DockOne.io undefined 知道创宇爬虫题- ...
- 常用js效果:选项卡切换
js选项卡,很多网站都会用到,我这里用jquery给整了一个简单但是却很实用的js选项卡,废话不多说,直接上代码: <style> .txtadsblk01{ width:200px;} ...
- Android开发之点九图的制作说明
总结: 左边的点代表垂直拉伸的区域, 上边的点代表水平拉伸的区域. 右边的点代表文字等的垂直可可显示区域. 下边的点代表文字等的水平可显示区域. 左上重合的区域就是拉伸区域. 右下重合的区域就是显示区 ...
- android invalidate 执行流程详解
invalidate()函数的主要作用是请求View树进行重绘,该函数可以由应用程序调用,或者由系统函数间接 调用,例如setEnable(), setSelected(), setVisiblity ...
- JavaBean中DAO设计模式介绍(转)
一.信息系统的开发架构 客户层-------显示层-------业务层---------数据层---------数据库 1.客户层:客户层就是客户端,简单的来说就是浏览器. 2.显示层:JSP/Ser ...
- C#生成XML的三种途径
C#生成XML的三种途径 为了全面,这里都将XML保存到文件中,有三种生成XML的方式: 1.我认为是最原始,最基本的一种:利用XmlDocument向一个XML文件里写节点,然后再利用XmlDocu ...