JavaScript Syntax and variable types || JavaScript 语法与变量类型

JavaScript 语法

区分大小写

如变量名、函数名及其他一切方法、属性等

JavaScript 允许不以;来结束一段代码

当不使用;时,代码的结束与否是由程序来决定的,当你写的这段代码与程序遵循的规则不符合时,执行结果很可能会不如人意

因此推荐使用;来结束一段代码,当您对 JavaScript 的了解足够深入后,可以在需要以;划分段落的时候才使用;


脚本注释:

// 单行注释
/* 多行注释 */

{}大括号包括其中的代码表示这是一个代码块

变量的定义:用于存储数据值的容器

变量需要使用 var 关键字来声明

命名规则:以字母、数字、$符、下划线构成,但是不能以数字开头

变量名不可使用系统的保留字进行命名


JavaScript 数据类型

数据类型:

  • undefined 类型,未定义 该类型的值只有 undefined
  • null 类型(对象),空值 该类型的值只有 null
  • boolean 类型,布尔值 该类型的值只有两个:true 和 false
  • number 类型,数字 该类型的值包含整数(包含八进制和十六进制)、浮点数、NaN(not a number)
  • string 类型,字符串 该类型的值可以是引号中的任意文本,该类型的变量可以用下标(索引)取出对应的字符。该类型的变量可以用 .length 求得字符串长度
  • object 引用类型,对象。它是所有类的基类引用类型通常被称为类(class),也就是说,遇到引用值,所处理的就是对象
    Object 对象中所有的属性和方法都会出现在其他对象中

类型转换:

Number() 把传递的参数转换成数值,如果无法转换为数字,则返回 NaN

Boolean() 把传递的参数转换成 Boolean 类型的值

String() 把传递的参数转换成字符串

*parseInt() 把传递的参数转换为整数

*parseFloat() 把传递的参数转换为浮点数

isNaN() 检测传递的参数是否不是一个数字

  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
Beginning JavaScript with DOM Scripting and Ajax, 2nd Edition (pdf + ePub) by Russ Ferguson and Christian Heilmann Publisher: Apress; 2nd Edition (July 2013) Language: English ISBN-10: 1430250925 ISBN-13: 978-1430250920 BOOK DESCRIPTION Beginning JavaScript with DOM Scripting and Ajax is an essential resource for modern JavaScript programming. This completely updated second edition covers everything you need to know to get up-to-speed with JavaScript development and add dynamic enhancements to web pages, right from the basics. As well as focusing on client-side JavaScript, you will also learn how to work with the Browser Object Model, the Document Object Model (DOM), how to use XML and JSON as well as communicate with service side scripts such as PHP. Find out how to: Construct good JavaScript syntax following modern coding practices Use JavaScript to communicate with the server and retrieve data Dynamically manipulate markup, validate forms and deal with images Debug applications using features inside the browser JavaScript is one of the most important technologies on the web. It provides the means to add dynamic functionality to your web pages and serves as the backbone of Ajax-style web development. Beginning JavaScript with DOM Scripting and Ajax will take you from being a JavaScript novice to work freely with this important technology – begin your JavaScript journey today! What you'll learn What functions, variables, events and objects are and how to use them. How build a site that will still work in the case that JavaScript is turned off. How to access and update part of the page using code. How to use JavaScript to communicate with the server and retrieve data. How to use JavaScript to for form validation and user feedback. How to use Third-Party Libraries like jQuery. Who this book is for Beginning JavaScript with DOM Scripting and Ajax is for the person who has a good grasp of HTML and CSS but wants to add JavaScript to their skillset. If you want to learn some basic programming concepts, have experience but need help updating your skills, or you’re coming from another language, Beginning JavaScript with DOM Scripting and Ajax can help. Table of Contents Chapter 1. Getting Started with JavaScript Chapter 2. Data and Decisions Chapter 3. From DHTML to DOM Scripting Chapter 4. HTML and JavaScript Chapter 5. Presentation and Behavior (CSS and Event Handling) Chapter 6. Common Uses of JavaScript: Images and Windows Chapter 7. JavaScript and User Interaction: Navigation and Forms Chapter 8. Back-End Interaction with Ajax and Node.js Chapter 9. Data Validation Techniques Chapter 10. Modern JavaScript Case Study: A Dynamic Gallery Chapter 11. Using Third-Party JavaScript Appendix A. Debugging JavaScript

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值