廖雪峰JavaScript教程
birth: 1990, 4. school: 'No.1 Middle School', 5. height: 1.70, 6. weight: 65, 7. score: null 8. }; JavaScript用一个 {…} 表示一个对象,键值对以 xxx: xxx 形式申明,用 , 隔开。注意,最 后一个键值对不需要在末尾加 , ,如果加了,有的浏览器(如低版本的IE)将报错。 birth: 1990, 4. school: 'No.1 Middle School', 5. height: 1.70, 6. weight: 65, 7. score: null 8. }; 2.5 对象 - 32 - 本文档使用 书栈(BookStack.CN) 构建 9. 'name' in xiaoming; // true 10. 'grade' lazy_sum() 时,每次调用都会返回一个新的函数,即使传入相同的参 数: 1. var f1 = lazy_sum([1, 2, 3, 4, 5]); 2. var f2 = lazy_sum([1, 2, 3, 4, 5]); 3. f1 === f2; // false f1() 和 f2() 的调用结果互不影响。 注意到返回的函数在其定义内部引用了局部变量 arr0 码力 | 264 页 | 2.81 MB | 10 月前3Julia 1.10.7 Documentation
type. "Fast" arrays like NumPy arrays that store elements in-place (i.e., dtype is np.float64, [('f1', np.uint64), ('f2', np.int32)], etc.) can be rep- resented by Array{T} where T is a concrete, immutable Musical Keyboard U+1F3BA \:trumpet: Trumpet U+1F3BB \:violin: Violin U+1F3BC \:musical_score: Musical Score U+1F3BD \:run- ning_shirt_with_sash: Running Shirt With Sash U+1F3BE \:tennis: Tennis states that calling with certain argtypes is a part of public API. For example, the change between f1 and f2 in the example below is usually considered compatible because the change is invisible by the0 码力 | 1691 页 | 6.34 MB | 10 月前3Julia 1.10.6 Documentation
type. "Fast" arrays like NumPy arrays that store elements in-place (i.e., dtype is np.float64, [('f1', np.uint64), ('f2', np.int32)], etc.) can be rep- resented by Array{T} where T is a concrete, immutable Musical Keyboard U+1F3BA \:trumpet: Trumpet U+1F3BB \:violin: Violin U+1F3BC \:musical_score: Musical Score U+1F3BD \:run- ning_shirt_with_sash: Running Shirt With Sash U+1F3BE \:tennis: Tennis states that calling with certain argtypes is a part of public API. For example, the change between f1 and f2 in the example below is usually considered compatible because the change is invisible by the0 码力 | 1691 页 | 6.33 MB | 10 月前3julia 1.10.8 documentation
type. "Fast" arrays like NumPy arrays that store elements in-place (i.e., dtype is np.float64, [('f1', np.uint64), ('f2', np.int32)], etc.) can be rep- resented by Array{T} where T is a concrete, immutable Musical Keyboard U+1F3BA \:trumpet: Trumpet U+1F3BB \:violin: Violin U+1F3BC \:musical_score: Musical Score U+1F3BD \:run- ning_shirt_with_sash: Running Shirt With Sash U+1F3BE \:tennis: Tennis states that calling with certain argtypes is a part of public API. For example, the change between f1 and f2 in the example below is usually considered compatible because the change is invisible by the0 码力 | 1692 页 | 6.34 MB | 8 月前3Julia 1.11.0-rc4 Documentation
type. "Fast" arrays like NumPy arrays that store elements in-place (i.e., dtype is np.float64, [('f1', np.uint64), ('f2', np.int32)], etc.) can be rep- resented by Array{T} where T is a concrete, immutable Musical Keyboard U+1F3BA \:trumpet: Trumpet U+1F3BB \:violin: Violin U+1F3BC \:musical_score: Musical Score U+1F3BD \:running_shirt_with_sash: Running Shirt With Sash U+1F3BE \:tennis: Tennis Racquet states that calling with certain argtypes is a part of public API. For example, the change between f1 and f2 in the example below is usually considered compatible because the change is invisible by the0 码力 | 1985 页 | 6.67 MB | 10 月前3Julia 1.11.0 Documentation
type. "Fast" arrays like NumPy arrays that store elements in-place (i.e., dtype is np.float64, [('f1', np.uint64), ('f2', np.int32)], etc.) can be rep- resented by Array{T} where T is a concrete, immutable Musical Keyboard U+1F3BA \:trumpet: Trumpet U+1F3BB \:violin: Violin U+1F3BC \:musical_score: Musical Score U+1F3BD \:running_shirt_with_sash: Running Shirt With Sash U+1F3BE \:tennis: Tennis Racquet states that calling with certain argtypes is a part of public API. For example, the change between f1 and f2 in the example below is usually considered compatible because the change is invisible by the0 码力 | 1987 页 | 6.67 MB | 10 月前3Julia 1.11.2 Documentation
type. "Fast" arrays like NumPy arrays that store elements in-place (i.e., dtype is np.float64, [('f1', np.uint64), ('f2', np.int32)], etc.) can be rep- resented by Array{T} where T is a concrete, immutable Musical Keyboard U+1F3BA \:trumpet: Trumpet U+1F3BB \:violin: Violin U+1F3BC \:musical_score: Musical Score U+1F3BD \:running_shirt_with_sash: Running Shirt With Sash U+1F3BE \:tennis: Tennis Racquet states that calling with certain argtypes is a part of public API. For example, the change between f1 and f2 in the example below is usually considered compatible because the change is invisible by the0 码力 | 2007 页 | 6.73 MB | 10 月前3Julia 1.11.1 Documentation
type. "Fast" arrays like NumPy arrays that store elements in-place (i.e., dtype is np.float64, [('f1', np.uint64), ('f2', np.int32)], etc.) can be rep- resented by Array{T} where T is a concrete, immutable Musical Keyboard U+1F3BA \:trumpet: Trumpet U+1F3BB \:violin: Violin U+1F3BC \:musical_score: Musical Score U+1F3BD \:running_shirt_with_sash: Running Shirt With Sash U+1F3BE \:tennis: Tennis Racquet states that calling with certain argtypes is a part of public API. For example, the change between f1 and f2 in the example below is usually considered compatible because the change is invisible by the0 码力 | 1989 页 | 6.68 MB | 10 月前3julia 1.11.3 documentation
type. "Fast" arrays like NumPy arrays that store elements in-place (i.e., dtype is np.float64, [('f1', np.uint64), ('f2', np.int32)], etc.) can be rep- resented by Array{T} where T is a concrete, immutable Musical Keyboard U+1F3BA \:trumpet: Trumpet U+1F3BB \:violin: Violin U+1F3BC \:musical_score: Musical Score U+1F3BD \:running_shirt_with_sash: Running Shirt With Sash U+1F3BE \:tennis: Tennis Racquet states that calling with certain argtypes is a part of public API. For example, the change between f1 and f2 in the example below is usually considered compatible because the change is invisible by the0 码力 | 2007 页 | 6.73 MB | 8 月前3阮一峰 JavaScript 教程
f() { 6. console.log('2'); 7. } 8. 9. f() // 1 函数的 name 属性返回函数的名字。 1. function f1() {} 2. f1.name // "f1" 如果是通过变量赋值定义的函数,那么 name 属性返回变量名。 1. var f2 = function () {}; 2. f2.name // "f2" 但 3. function f1() { 4. console.log(n); 5. } 6. f1() // 999 函数的其他知识点 闭包 函数 - 129 - 本文档使用 书栈(BookStack.CN) 构建 上面代码中,函数 f1 可以读取全局变量 n 。 但是,函数外部无法读取函数内部声明的变量。 1. function f1() { 2. var n ReferenceError: n is not defined( 上面代码中,函数 f1 内部声明的变量 n ,函数外是无法读取的。 如果出于种种原因,需要得到函数内的局部变量。正常情况下,这是办 不到的,只有通过变通方法才能实现。那就是在函数的内部,再定义一 个函数。 1. function f1() { 2. var n = 999; 3. function f2() {0 码力 | 540 页 | 3.32 MB | 10 月前3
共 117 条
- 1
- 2
- 3
- 4
- 5
- 6
- 12