import我想在执行语法内的代码之前运行几个代码。
例子
file-1.js
console.log('Inside File 1')
import './file-2.js'
Run Code Online (Sandbox Code Playgroud)
file-2.js
console.log('Inside File 2')
Run Code Online (Sandbox Code Playgroud)
输出
Inside File 2
Inside File 1
Run Code Online (Sandbox Code Playgroud)
我期望的输出
Inside File 1
Inside File 2
Run Code Online (Sandbox Code Playgroud)
环境
v12.19.0具有模块配置的Node JS
真实案例
文件1.js
process.env.SHARED_DATA = 'Hello world'
import './file-2.js'
Run Code Online (Sandbox Code Playgroud)
文件2.js
console.log(process.env.SHARED_DATA)
Run Code Online (Sandbox Code Playgroud)
输出
undefined
Run Code Online (Sandbox Code Playgroud) 当然,这又花了 20 万年才发生。但是在 的值超过 的值后,Javascript约会系统会出错吗?会发生什么后果?Date.now()Number.MAX_SAFE_INTEGER
也许这个问题看起来很奇怪而且没用。但是任何人都可以回答我的好奇心以及其他可能有相同问题的人。
即使我认为我已经返回了正确的类型数据,我也得到了预期的类型参数。我处于rust通用材料的学习阶段。
struct Cat {
weight: i32,
}
trait Animal{
fn get_weight<T>(&self) -> T;
}
impl Animal for Cat {
fn get_weight<i32>(&self) -> i32 {
self.weight // I got error in here
}
}
fn main() {}
Run Code Online (Sandbox Code Playgroud)
错误信息:
mismatched types
expected type parameter, found i32
note: expected type `i32` (type parameter)
found type `i32` (i32)
expected `i32` because of return type
expected type parameter, found i32
Run Code Online (Sandbox Code Playgroud) javascript ×2
date ×1
ecmascript-6 ×1
import ×1
module ×1
node.js ×1
numbers ×1
rust ×1
traits ×1
types ×1