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 ...
随机推荐
- Ubuntu下安装Apache2, php5 mysql
不错的博文:http://blog.csdn.net/guaikai/article/details/6905781 1:首先安装apache:打开终端(ctrl+Alt+t), 输入命令:sudo ...
- 机器学习笔记1——Introduction
Introduction What is Machine Learning? Two definitions of Machine Learning are offered. Arthur Samue ...
- 事物复制中大项目(Large Article)出问题如何快速修复
事物日志中如果大的发布项目(Article)出问题了,并且影响了系统的使用,如何快速的解决? 一般的做法是重新用快照或者备份初始化,但是如果出问题的表非常大(上亿的记录,几十GB的数据),使用初始化是 ...
- 8-6-Exercise
HDU 1003 Max Sum 题意:给出一串数字,求出其中某段连续的数字之和最大的值,同时要输出起点的位置和终点的位置~~~ 方法一: 用sum记录某一段和的值,maxx为目前为止最大的su ...
- 谈JAVA的内存回收(一)
谈JAVA的内存回收 程序员需要通过关键字new创建Java对象,即可视为Java对象申请内存空间,JVM会在堆内存中为每个对象分配空间,当一个Java对象失去引用时,JVM的垃圾回收机制会自动清除他 ...
- HDU 2102 A计划(三维BFS)
这题太欢乐了......虽然wa了几次,但是想到骑士在两幅图的传送门中传来传去就觉得这骑士太坑了 #include <cstdio> #include <iostream> # ...
- 常用对象API、附加:集合补充
基本数据类型对象包装类: 为了方便操作基本数据类型值,将其封装成了对象,在对象中定义了属性和行为丰富了该数据的操作. 用于描述该对象的类就称为基本数据类型对象包装类. byte——Byte short ...
- ACMDP之最长公共子序列长度—HDU1159
Common Subsequence Problem Description A subsequence of a given sequence is the given sequence with ...
- 我是怎么拿到百度2016校招Offer的——IT技术类校招成功面经
笔者是软件工程大四学生,属于保研失败群体,不想考研,所以选择了工作.从9月下保研失败到10月中成功拿到百度Offer,这其中的大起大落真是外人所无法体会的.这一段时间的面试经验,可以和大家分享一下.笔 ...
- IOS关于XIB文件和调试时候显示不一样问题
1 前言 今天工作中,遇到了一个xib文件布局问题,具体问题如下:在xib中加了一个图片,背景为已经切好的图片,但是当显示在模拟器上面的时候却显示不出来效果. 2 详述 2.1 问题截图 如 ...