textjavascript和jquery调试技巧(代码片段)

author author     2022-11-30     167

关键词:

*@channel I know this program is difficult, rigorous, and fast-paced... all this drinking from the firehose has a way of wearing you down, and making you doubt yourself. Know that the TAs and I support each of you entirely in this process. These guidelines/steps below might feel a little bit like tough love, but I recommend thinking of them more as a guide towards becoming a more confident, self-sufficient developer and debugger. Hang in there, ladies; keep coding, reviewing, and scanning your code critically for errors. It will all pay off!* _Consider starring this message so you can use it for further reference!_


*A few steps for debugging your JavaScript:*

1.) If your code isn’t working as expected, *ALWAYS* open up the console to see if there are any error messages. If you find any errors, read them critically and try to determine what the problem is. Note that over on the right hand side of the error message, the console provides the line number within your JavaScript to help you narrow down the problem code.

2.) Verify that all references to variable names are spelled correctly, that strings have matching opening and closing quotes, and that your function/loop/if/etc brackets and parentheses close in the correct places. Proofread your code with a very critical eye — JavaScript is very unforgiving in regards to tiny syntax errors. Learn to detect small differences and bugs in your own code.

3.) If you’re unable to puzzle out a fix for an error message, *try some Google Fu!*

4.) Let your error messages teach you! Everytime you discover and troubleshoot (or get help with) an error, try to commit as much of the experience as possible to memory. Over time, you'll start to recognize error messages based on prior experience. Part of being a strong developer is having been around the error message block enough to remember the causes (and fixes!) for common bugs. Every error you tackle and triumph over will make you just a liiiiiiittle bit better at fixing later errors!

5.) Remember that updating variables in your JavaScript will *not* update those values on the HTML page. You’ll have to do that with either JavaScript or jQuery.

6.) Remember that one equal sign `=` *sets* a value, while two/three equal signs `==` or `===` *evaluate*.

7.) A plus sign `+` will add if the values are numbers or will concatenate if the values are strings.



*A couple items to verify:*

1.) Always verify that your JavaScript files are loading correctly. Remember that relative paths are used in your HTML files and tell your HTML how to “find” your JavaScript or CSS files. A quick way to check whether your file is loading is to place an alert on the very first line of your JavaScript file: `alert(“Testing”)`.

2.) If you’re using jQuery `$`, make sure you have a link to jQuery AND that your code using jQuery is linked *after* the jQuery CDN link.

3.) If you are using jQuery and linking you .js file from the HTML page’s `<head>` tag, make sure to wrap your code in a `$(document).ready(...)`: http://learn.jquery.com/using-jquery-core/document-ready/ (If you don’t have a $(document).ready(), your JavaScript will try to execute before the HTML it interacts with has rendered, which will likely break your code!)

4.) Else, make sure your .js file is instead linked from the very bottom of the `<body>` tag.

5.) If click events aren’t triggering on dynamically-generated elements (ie those created/placed by JavaScript) then look into event delegation: https://learn.jquery.com/events/event-delegation/

textjavascript的jquery的とのチートサイト集(代码片段)

查看详情

101个mysql调试和优化技巧

101个MySQL调试和优化技巧MySQL是一个功能强大的开源数据库。随着越来越多的数据库驱动的应用程序,人们一直在推动MySQL发展到它的极限。这里是101条调节和优化MySQL安装的技巧。一些技巧是针对特定的安装环境的,但这... 查看详情

javascript调试技巧(代码片段)

...ole.timeEnd()测试循环console.log()和console.dir()的区别阐述我们调试Javascript一般会用到Chrome和Firefox的控制台作为调试工具,本文列出了几条用于调试Javascript的技巧,掌握它们 查看详情

javascript调试技巧(代码片段)

...ole.timeEnd()测试循环console.log()和console.dir()的区别阐述我们调试Javascript一般会用到Chrome和Firefox的控制台作为调试工具,本文列出了几条用于调试Javascript的技巧,掌握它们 查看详情

jquery中ajax使用error调试错误的方法,实例分析了ajax的使用方法与error函数调试错误的技巧

代码:$(document).ready(function()           jQuery("#clearCac").click(function()            查看详情

在特定状态下调试浏览器的建议和技巧?

】在特定状态下调试浏览器的建议和技巧?【英文标题】:Suggestion&Tipstodebugthebrowseronspecificstate?【发布时间】:2014-07-1611:23:44【问题描述】:是否有在特定状态下调试浏览器的解决方案?举个例子:我想将typeahead.js与twitterboot... 查看详情

.NET 的 Visual Studio 调试器提示和技巧

】.NET的VisualStudio调试器提示和技巧【英文标题】:VisualStudiodebuggertips&tricksfor.NET【发布时间】:2010-09-1702:50:03【问题描述】:多年来我一直在使用VS的调试器,但时不时会遇到一个我以前从未注意到的功能,然后想“该死!我... 查看详情

c语言进阶学习笔记七程序执行+调试技巧(实用技巧篇)(代码片段)

...符串④define宏名(参数表)字符串⑤宏和函数对比二、调试技巧篇①什么是bug?②调试是什么?有多重要?③debug和release的介绍④windows环境调试介绍⑥如何写出好(易于调试)的代码?一、程序执行篇程序的翻译... 查看详情

vs编译器实用调试技巧

一、Debug和Release的区别debug通常称为调试版本,它包含调试信息,并且不做任何优化,便于程序员调试程序。release称为发布版本,他往往是进行了各种优化,使得程序在代码大小和运行速度上都是最优的,以便用户很好使用代码... 查看详情

javascript调试技巧

...ugger;’除了console.log,debugger;是我们最喜欢、快速且肮脏的调试工具。一旦执行到这行代码,Chrome会在执行时自动停止。你甚至可以使用条件语句加上判断,这样可以只在你需要的时候运行。愚人码头注:本人实在觉得这种调试方... 查看详情

调试接口小技巧-通过接口调试工具去下载上传文件

前言在一些开发场景,比如文件的下载,在我们自己调试的时候,会有一些伙伴不知道怎么调试,其实是和普通的接口一样的,只是有一些小技巧,多余的设置需要知道我最常用的两个接口调试工具是PostMan和ApiFox,我就主要这两个工具进... 查看详情

什么是最佳的通用调试技巧?

】什么是最佳的通用调试技巧?【英文标题】:Whatarethebestgeneralpracticedebuggingtricks?【发布时间】:2011-05-2706:54:33【问题描述】:什么是最佳的常规调试技巧?不是与特定平台、语言等相关联的那些,而是那些你发现你使用的那些... 查看详情

调试技巧

项目能打断点调试(最高效):先估计哪里出问题并打断点,如果不知道,就只能在入口处打断点;然后运行程序一步一步调试。项目不能断点调试(如代码发布到生产环境、调试环境坏掉了):方法1:在关键环节输出日志,... 查看详情

实用调试技巧(代码片段)

调试技巧调试是什么?有多重要?一、调试的基本步骤二、Debug和Release的介绍。三、学会快捷键四、调试的时候查看程序当前信息五.实例实例一实例二六.如何写出好(易于调试)的代码示范注意七.编程常见错误... 查看详情

wkwebview和uiwebview调试技巧

...发过程中,碰到某个界面有问题需要陪着web开发人员进行调试测试,这是一个非常揪心的问题。所以必须掌握safari对webview进行调试的技巧。1、打开模拟器(真机)的开发者模式【设置】->【Safari】->【高级】->【Web检查器... 查看详情

vs环境——c语言实用调试技巧(代码片段)

目录什么是bug?调试的目的调试的基本步骤Debug和Release的介绍windows环境调试介绍 1.选择Debug调试版本 2.学会快捷键 3.调试窗口的使用 1.局部变量窗口  2.监视窗口 3.内存查看窗口 4.调用堆栈窗口什么是bug?bug是计算... 查看详情

需要调试 Cocoa 绑定的技巧

】需要调试Cocoa绑定的技巧【英文标题】:NeedtipsfordebuggingCocoabindings【发布时间】:2012-08-1815:40:07【问题描述】:我在三天内遇到了第二个问题,错误的绑定导致我数小时的搜索和头痛。查看堆栈跟踪表明调试存在问题(例如,... 查看详情

visualstudio高效调试手段与技巧总结,值得收藏!

...g下的报错弹框,点击重试,查看函数调用堆栈3、调试时,程序和调试器都发生了闪退,可以尝试到Output窗口中找线索4、被废弃的API函数IsBadReadPtr和IsBadWritePtr5、条件断点与临时过滤条件6、数据断点7、附加 查看详情