博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
javascript的调试
阅读量:7113 次
发布时间:2019-06-28

本文共 4282 字,大约阅读时间需要 14 分钟。

主流浏览器

IE6.0还支持一级DOM事件模型和Internet Explorer增强事件模型,部分支持W3C的二级DOM事件模型.

关于事件模型

IE7.0浏览器支持JScript5.7,该版本在JScript基础上有所增强,但与ECMA v3标准仍热是基本一致

在数据交互方面,JScript+ 5+支持 MSXML 4.0 组件,在外部接口方面,JScript5+完全兼容COM+/DCOM标准

 

原始调试方法-----利用输出语句,"反射"机制和调试对象来进行调试

在编写代码中遇到的问题,最原始的调试方法在程序中直接插入调试逻辑和输出语句.

定位代码和调用堆栈:
一款适合的调试工具可以帮助你迅速定位错误代码和切入调用队堆栈.让工具帮你纠错,这样你就能够把更多的精力投入到实际的设计和编码实现中.

step by step
在切入调试过程中,可以控制代码单步执行.调试过程中的切入点被称作为"断点",通常在程序中可以人为调试器设置若干个"断点",启动调试程序后,调试器便会按照次序依次切入这些断点进行调试.

异常处理机制:-----一个try/catch/finally模式的例子
js的异常处理机制是非常标准的try/catch/finally模式.
js是弱类型语言,不能通过声明catch的参数类型来捕获不同类型的异常.不过通过实例判断可以很容易地区分和处理不同的异常.

+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

你应该让你的js的格式和你网页的格式采用相同的格式.
如果js选中gbk或者其他格式将有其他的错误产生.

parseFloat 方法
返回字符串转换得到的浮点数
必选项numString参数是包含浮点数的字符串

parseFloat()反悔的numString保存相同的数字表示

parseFloat("1.2abc"); //返回1.2
parseFloat("abc"); //返回NaN
可以用isNaN来检测NaN

 

运算符"/"对两个运算数进行代数除法操作.如果运算数是非数值,运算符"/"会将他们进行转换.

ECMAScripts users C-style comments for both single-line and block comments.

comments:注释,解释
A single-line comments begins with two forward-slash characters,such as this:
// this is it
forward-slash 斜线

A block comments begins with a forward slash and asterisk(*) and ends with the opposite(*),as in this example.

/*
* This is a muli-line
*/
Strict Mode 严格遵循标准模式

specify: 指定;详细说明;列举;把...什么加入说明书

execute:执行,实行,处死

Even though a semicolon is not required at the end of statement,it is recommended to always include one.Including semicolons helps prevent errors of omission,such as not finishing what you were typing,all allows developers to compress ECMAScript code by removing extra white space.

semicolon:分号

if()test

variables:变量
ECMAScript variables are loosely typed,meaning that a variable can hold any type of data.Every variable is simply a named placeholder for a value. To define a varibale,use the var operator(note that var is a keyword) follow by the varibable name(an identifier,as described earlier),like this:
var message

This code defines a variable named message that can be used to hold any value.To define a varibale, use the var operator(note that var is a keyword) followed by the variable name(an identifier,as describute earlier),like this :

var message

Here, message is defined value of "hi".Doing this initialization doesn't mark the variable as beinga string tyepe;it is simply the assignment of a value of

var message = "hi";

message = 100; //legal, but no recommended
legal 法律的,but no recommended 可以使用,但不是推荐的

The typeof the Operate
Because ECMAScript is loosely typed,there needs to be a way to determime the data type of a given variables.The typeof provides that information.Using the typeof operation on a value returns one of the following strings.

"undefined" if the value if undefined.

"boolean" if the value is a Boolean
"string" if the values is a string
"number" is the values is number
"object" is the value is object
"function" if the value is a function

The typeof operator is called like this.

var message = "some string"

alert(typeof(message))
alert(typeof(message))
alert(typeof(199))

Be aware there are a few cases where typeof seemingly returns a confusing but technically correct value.Calling typeof null returns a value of "object", as the special value null is considered to be an empty object reference.

The Undefined Type:
The Undefined type has only one value, which is the special value undefined.When a variable is declared using var but not initalized, it is assigned the value of undefined as follows.

declare:公开的,公布宣布的

Note that a variable containing the value of undefined is a different from a variable that hasn't been defined at all.
consider:考虑仔细,细想

In this example, the first alert displays the variable message,which is "undefined".In the second alert,an undeclared variable called age is passed into the alert() function.but this isn't very useful and in fact throws an error strict mode.

operator:经营者,操作员,话务员,行家

When defining a variable that is meant to later hold on object,it is advisable to initalize the variable to null as opposed to anything else.That way, you can explictly check for the value to determine if the variable has been filled with an object reference at a later time,such as in this example.

转载于:https://www.cnblogs.com/sgsheg/archive/2012/11/22/2782924.html

你可能感兴趣的文章
NLPIR:数据挖掘深度决定大数据应用价值
查看>>
Flex 布局教程
查看>>
GET和POST两种基本请求方法的区别
查看>>
Webpack4 学习笔记 - 01:webpack的安装和简单配置
查看>>
二)golang工厂模式
查看>>
React 教程:快速上手指南
查看>>
Python 的 heapq 模块源码分析
查看>>
Jitsi快捷安装
查看>>
区块链技术的基本特点
查看>>
阿里云容器服务DaemonSet实践
查看>>
一个游戏拨账系统的数据库结算设计
查看>>
Kafka Network层解析
查看>>
css加载会造成阻塞吗?
查看>>
聊聊storm TridentWindowManager的pendingTriggers
查看>>
React 解决fetch跨域请求时session失效
查看>>
翻译_只需20行代码创造JavaScript模板引擎(二)
查看>>
Blockchain和Tangle哪一个是未来?
查看>>
apicloud拉起小程序并传递参数
查看>>
虚拟机Centos6.8安装MYSQL5.7,本地Navicat连接
查看>>
简单聊聊DOM
查看>>