廖雪峰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 月前3ES6 Tutorial
.............. 21 The var keyword ................................................................................................................................... 22 var and hoisting .......... ................ 22 var and block scope ............................................................................................................................... 23 var and block level safety used keywords are listed in the following table. break as any Switch case if throw Else var number string Get module type instanceof Typeof finally for enum Export while void0 码力 | 435 页 | 4.00 MB | 1 年前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 月前3阮一峰 《ECMAScript 6入门》 第三版
babel-core 模块。 安装命令如下。 $ npm install babel-core --save ECMAScript 6简介 15 然后,在项目中就可以调用 babel-core 。 var babel = require('babel-core'); // 字符串转码 babel.transform('code();', options); // => { code, map, ast } 配置对象 options ,可以参看官方文档http://babeljs.io/docs/usage/options/。 下面是一个例子。 var es6Code = 'let x = n => n + 1'; var es5Code = require('babel-core') .transform(es6Code, { presets: ['latest'] console.log('Calc constructor'); } add(a, b) { return a + b; } } var c = new Calc(); console.log(c.add(4,5)); ECMAScript 6简介 20 正常情况下,上面代码会在控制台打印出 9 。0 码力 | 679 页 | 2.66 MB | 1 年前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 月前3Computer Programming with the Nim Programming Language
which is supposed to convert a string to an integer, does not compile. Can you fix it? `var s: string = "123"; var i: int = int(s)` Yes, the code you provided is not valid Nim syntax. In order to convert procedure from the strutils module. Here is an example of how to use it: import strutils var s: string = "123" var i: int = parseInt(s) echo i # Output: 123 7 In this example, we import the strutils module we would write it like from std/strformat import fmt const DefaultWorldRange = [0.0, 0, 800, 600] var str: string for i, x in pairs(DefaultWorldRange): str.add(fmt("{x:g}")) if i < DefaultWorldRange0 码力 | 512 页 | 3.54 MB | 1 年前3Computer Programming with the Nim Programming Language
which is supposed to convert a string to an integer, does not compile. Can you fix it? `var s: string = "123"; var i: int = int(s)` Yes, the code you provided is not valid Nim syntax. In order to convert procedure from the strutils module. Here is an example of how to use it: import strutils var s: string = "123" var i: int = parseInt(s) echo i # Output: 123 7 In this example, we import the strutils module we would write it like from std/strformat import fmt const DefaultWorldRange = [0.0, 0, 800, 600] var str: string for i, x in pairs(DefaultWorldRange): str.add(fmt("{x:g}")) if i < DefaultWorldRange0 码力 | 508 页 | 3.50 MB | 1 年前3Computer Programming with the Nim Programming Language
which is supposed to convert a string to an integer, does not compile. Can you fix it? `var s: string = "123"; var i: int = int(s)` Yes, the code you provided is not valid Nim syntax. In order to convert procedure from the strutils module. Here is an example of how to use it: import strutils var s: string = "123" var i: int = parseInt(s) echo i # Output: 123 7 In this example, we import the strutils module we would write it like from std/strformat import fmt const DefaultWorldRange = [0.0, 0, 800, 600] var str: string for i, x in pairs(DefaultWorldRange): str.add(fmt("{x:g}")) if i < DefaultWorldRange0 码力 | 512 页 | 3.53 MB | 1 年前3
共 1000 条
- 1
- 2
- 3
- 4
- 5
- 6
- 100