This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # 引言 # | |
| 我们知道变量用来存储数据,一个变量只能存储一个内容。假设你想存储10个人的姓名或者存储20个人的数学成绩,就需要10个或20个变量来存储,如果需要存储更多数据,那就会变的更麻烦。我们用数组解决问题,一个数组变量可以存放多个数据。 | |
| # 数组定义 # |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # String对象 # | |
| String对象用于处理文本(字符串) | |
| 语法: | |
| var a = new String(s); | |
| 其中参数s是要存储在String对象中或转换成原始字符串的值。 | |
| 返回值:当 String() 和运算符 new 一起作为构造函数使用时,它返回一个新创建的 String 对象,存放的是字符串 s 或 s 的字符串表示。 | |
| 当不用 new 运算符调用 String() 时,它只把 s 转换成原始的字符串,并返回转换后的值。 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Math 对象属性 # | |
| E | |
| PI | |
| # Math 对象方法 # | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # 函数 # | |
| 定义:函数是由事件驱动的或者当它被调用时执行的可重复使用的代码块。 | |
| 简而言之:什么是函数? | |
| 函数是一组可以随时随地运行的语句。 | |
| 函数是ECMAScript的核心 | |
| 作用: | |
| 使程序变得更简短而清晰 | |
| 有利于程序维护 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # for # | |
| for语句对常用的循环模式做了一些简化。大部分的循环都具有特定的计数器变量。在循环开始之前要初始化这个变量,然后在每次循环执行之前都检测一下它的值。最后计数器变量做自增操作,否则就在循环结束后、下一次判断循环条件前做修改。在这一类循环中,计数器的三个关键操作就是初始化、检测和更新。for语句就将这三步操作明确声明为循环语句的一部分,各自使用一个表达式来表示。 | |
| # for语句的语法格式 # | |
| for(initialize;test;increment) statement |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # 语句的概念 # | |
| 表达式在javascript中是短语,那么语句就是javascript整句或命令。正如英文是用点号作结尾来分隔语句,javascript语句是以分号结束。 | |
| javascript程序无非就是一系列可执行语句的集合。 | |
| 分号 ; | |
| 分号用于分隔 JavaScript 语句。 | |
| 通常我们在每条可执行的语句结尾添加分号。 | |
| 使用分号的另一用处是在一行中编写多条语句。 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # 比较运算符 # | |
| 比较运算符在逻辑语句中使用,以测定变量或值是否相等。 | |
| ,用运算符号按一定的规则连接起来的、有意义的式子称为表达式。 | |
| # 运算符 # | |
| 运算符用于执行程序代码运算 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Object类型(对象) # | |
| “万物皆对象” | |
| JavaScript 中的所有事物都是对象:字符串、数值、数组、函数... | |
| 在 JavaScript 中,对象是拥有属性和方法的数据。 | |
| 此外,JavaScript 允许自定义对象。 | |
| # String类型(字符串) # |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # JavaScript变量 # | |
| 变量:值可以改变的量称为变量;变量占据一段内存,通过变量名字可以调用内存中的信息。 | |
| JavaScript中的变量没有类型,即弱类型语言。 | |
| 变量的语法: | |