廖雪峰JavaScript教程
; ,所有语句都会添加 ; 。 例如,下面的一行代码就是一个完整的赋值语句: 1. var x = 1; 下面的一行代码是一个字符串,但仍然可以视为一个完整的语句: 1. 'Hello, world'; 下面的一行代码包含两个语句,每个语句用 ; 表示语句结束: 1. var x = 1; var y = 2; // 不建议一行写多个语句! 语句块是一组语句的集合,例如,下面的代码先做了一个判断,如果判断成立,将执行 : 1. ! true; // 结果为false 2. ! false; // 结果为true 3. ! (2 > 5); // 结果为true 布尔值经常用在条件判断中,比如: 1. var age = 15; 2. if (age >= 18) { 3. alert('adult'); 4. } else { 5. alert('teenager'); 6. 0 : 1. var arr = [1, 2, 3.14, 'Hello', null, true]; 2. arr[0]; // 返回索引为0的元素,即1 3. arr[5]; // 返回索引为5的元素,即true 4. arr[6]; // 索引超出了范围,返回undefined JavaScript的对象是一组由键-值组成的无序集合,例如: 1. var person = {0 码力 | 264 页 | 2.81 MB | 10 月前3阮一峰 JavaScript 教程
书栈(BookStack.CN) 构建 行。一般情况下,每一行就是一个语句。 语句(statement)是为了完成某种任务而进行的操作,比如下面就 是一行赋值语句。 1. var a = 1 + 3; 这条语句先用 var 命令,声明了变量 a ,然后将 1 + 3 的运算结果 赋值给变量 a 。 1 + 3 叫做表达式(expression),指一个为了得到返回值的计算 式。语 语言中预期为值的地方,都可以使用表达式。比如,赋 值语句的等号右边,预期是一个值,因此可以放置各种表达式。 语句以分号结尾,一个分号就表示一个语句结束。多个语句可以写在一 行内。 1. var a = 1 + 3 ; var b = 'abc'; 分号前面可以没有任何内容,JavaScript引擎将其视为空语句。 1. ;;; 上面的代码就表示3个空语句。 表达式不需要分号结尾。一旦在表达式后面添加分号,则 变量是对“值”的具名引用。变量就是为“值”起名,然后引用这个名 字,就等同于引用这个值。变量的名字就是变量名。 1. var a = 1; 上面的代码先声明变量 a ,然后在变量 a 与数值1之间建立引用关 系,称为将数值1“赋值”给变量 a 。以后,引用变量名 a 就会得到 数值1。最前面的 var ,是变量声明命令。它表示通知解释引擎,要创 建一个变量 a 。 注意,JavaScript 的变量名区分大小写,0 码力 | 540 页 | 3.32 MB | 10 月前3MuPDF 1.23.0 Documentation
of the process of throwing that excep- tion. As a way of mitigating this problem, we provide a fz_var() macro that tells the compiler to ensure that that variable is not unset by the act of throwing the material m = NULL; walls w = NULL; roof r = NULL; house h = NULL; tiles t = make_tiles(); fz_var(w); fz_var(r); fz_var(h); fz_try(ctx) (continues on next page) 2.3. Error handling 9 MuPDF Documentation, level exception handler. If it succeeds, t will be set before fz_try starts, so there is no need to fz_var(t);. We try first off to make some bricks as our building material. If this fails, we fall back to0 码力 | 245 页 | 817.74 KB | 7 月前3MuPDF 1.25.0 Documentation
of the process of throwing that excep- tion. As a way of mitigating this problem, we provide a fz_var() macro that tells the compiler to ensure that that variable is not unset by the act of throwing the material m = NULL; walls w = NULL; roof r = NULL; house h = NULL; tiles t = make_tiles(); fz_var(w); fz_var(r); fz_var(h); (continues on next page) 2.3. Error handling 9 MuPDF Documentation, Release 1.25 level exception handler. If it succeeds, t will be set before fz_try starts, so there is no need to fz_var(t);. We try first off to make some bricks as our building material. If this fails, we fall back to0 码力 | 259 页 | 1.11 MB | 7 月前3MuPDF 1.24.0 Documentation
of the process of throwing that excep- tion. As a way of mitigating this problem, we provide a fz_var() macro that tells the compiler to ensure that that variable is not unset by the act of throwing the material m = NULL; walls w = NULL; roof r = NULL; house h = NULL; tiles t = make_tiles(); fz_var(w); fz_var(r); fz_var(h); (continues on next page) 2.3. Error handling 9 MuPDF Documentation, Release 1.24 level exception handler. If it succeeds, t will be set before fz_try starts, so there is no need to fz_var(t);. We try first off to make some bricks as our building material. If this fails, we fall back to0 码力 | 249 页 | 830.15 KB | 7 月前3Sender Patterns to Wrangle Concurrency in Embedded Devices
a2); 7 8 int var = 0; 9 10 11 | async::then<"before-wa-then">([](auto v){ things::var = v; }) 12 | async::seq(w) 13 | async::then<"last-then">([](auto ...){ ++things::var; }) 14 | a2); 7 8 int var = 0; 9 10 11 | async::then<"before-wa-then">([](auto v){ things::var = v; }) 12 | async::seq(w) 13 | async::then<"last-then">([](auto ...){ ++things::var; }) 14 | ings::s); 19 20 while(true) {} 21 } 22 | async::then<"before-wa-then">([](auto v){ things::var = v; }) namespace things { 1 int av = 0; 2 3 auto a0 = async::just<"just-a0">(0); 4 auto a1 =0 码力 | 106 页 | 26.36 MB | 5 月前3JavaScript 正则表达式迷你书 老姚 - v1.1
• 字符组 • 量词 • 分支结构 • 案例分析 1.1. 两种模糊匹配 如果正则只有精确匹配是没多大意义的,比如 /hello/,也只能匹配字符串中的 "hello" 这个子串。 var regex = /hello/; console.log( regex.test("hello") ); // => true 正则表达式之所以强大,是因为其能实现模糊匹配。 而模糊匹配,有两 个字符 "b",最后 是字符 "c"。 其可视化形式如下: JavaScript 正则表达式迷你书 1. 第一章 正则表达式字符匹配攻略 | 第 6 页 测试如下: var regex = /ab{2,5}c/g; var string = "abc abbc abbbc abbbbc abbbbbc abbbbbbc"; console.log( string.match(regex) ); [abc],表示该字符是可以字符 "a"、"b"、"c" 中的任何一个。 比如 /a[123]b/ 可以匹配如下三种字符串: "a1b"、"a2b"、"a3b"。 其可视化形式如下: 测试如下: var regex = /a[123]b/g; var string = "a0b a1b a2b a3b a4b"; console.log( string.match(regex) ); // => ["a1b", "a2b"0 码力 | 89 页 | 3.42 MB | 10 月前3JavaScript 正则表达式迷你书 老姚 - v1.0
• 字符组 • 量词 • 分支结构 • 案例分析 1.1. 两种模糊匹配 如果正则只有精确匹配是没多大意义的,比如 /hello/,也只能匹配字符串中的 "hello" 这个子串。 var regex = /hello/; console.log( regex.test("hello") ); // => true 正则表达式之所以强大,是因为其能实现模糊匹配。 而模糊匹配,有两 个字符 "b",最后 是字符 "c"。 其可视化形式如下: JavaScript 正则表达式迷你书 1. 第一章 正则表达式字符匹配攻略 | 第 6 页 测试如下: var regex = /ab{2,5}c/g; var string = "abc abbc abbbc abbbbc abbbbbc abbbbbbc"; console.log( string.match(regex) ); [abc],表示该字符是可以字符 "a"、"b"、"c" 中的任何一个。 比如 /a[123]b/ 可以匹配如下三种字符串: "a1b"、"a2b"、"a3b"。 其可视化形式如下: 测试如下: var regex = /a[123]b/g; var string = "a0b a1b a2b a3b a4b"; console.log( string.match(regex) ); // => ["a1b", "a2b"0 码力 | 89 页 | 3.42 MB | 10 月前3Game Development for Human Beings
we’ll add them into the game. main.js will be the following, the other files are empty for now: 1 var SpaceHipster = SpaceHipster || {}; 2 3 SpaceHipster.game = new Phaser.Game(window.innerWidth, window directly with game and the states names, but I’d recommend using it just for best practice. 1 var SpaceHipster = SpaceHipster || {}; Means that if the object exists already, we’ll use it. Otherwise time to load everything else with a nice and charming preload screen. Content of Boot.js: 1 var SpaceHipster = SpaceHipster || {}; 2 3 SpaceHipster.Boot = function(){}; 4 5 //setting game configuration0 码力 | 472 页 | 8.46 MB | 10 月前3Hello 算法 1.2.0 简体中文 Swift 版
+ 1, … , ? − 1 : // === File: iteration.swift === /* for 循环 */ func forLoop(n: Int) -> Int { var res = 0 // 循环求和 1, 2, ..., n-1, n for i in 1 ... n { res += i } return res } 第 2 章 复杂度分析 www ⋯ + ? : // === File: iteration.swift === /* while 循环 */ func whileLoop(n: Int) -> Int { var res = 0 var i = 1 // 初始化条件变量 // 循环求和 1, 2, ..., n-1, n while i <= n { res += i i += 1 // 更新条件变量 } // === File: iteration.swift === /* while 循环(两次更新) */ func whileLoopII(n: Int) -> Int { var res = 0 var i = 1 // 初始化条件变量 // 循环求和 1, 4, 10, ... while i <= n { res += i // 更新条件变量 i += 1 i *= 20 码力 | 379 页 | 18.48 MB | 9 月前3
共 158 条
- 1
- 2
- 3
- 4
- 5
- 6
- 16