在Chromes的Performance选项卡中运行JS脚本时,我发现JS解释有三个步骤:router.get('/:connectionType/users/:userType/:email/:password/', (req: Request, res: Response) => {
const service: AuthServices = new AuthServices(connection)
const { connectionType, userType, email, password } = req.params
let checkingUser: Promise<any> = service.checkUser(req, res)
.then(data => {
if (data[0]){
let checkingPassword: Promise<any> = service.checkPassword(req, res)
.then(data => {
const xdata = data[0]
xdata
? res.status(200).json({ userID: xdata['userID'] })
: res.status(401).json({ error: WRONG_PASSWORD })
})
.catch(err => res.status(500).json({ error: INTERNAL_ERROR }))
}
// my probleme is just here
else if (connectionType === 'signup') {
const query = stringify({
userType,
email,
password
})
// this is my redirect
res.redirect(`${ auth }/users?${ query }`)
}
else
res.status(401).json({ error: WRONG_EMAIL })
})
.catch(err => res.status(500).json({ error: INTERNAL_ERROR }))
})
,Parse
和Compile
。
有时我只会看到Evaluate
,有时会看到Evaluate
和Compile
,有时会看到整个三个。
我的问题是:
Evaluate
缺失)答案 0 :(得分:2)
解析:
js引擎遍历代码,确定所有不同的范围,变量声明等并对它们进行排序。在此步骤中也会发生吊装。基本上,您的纯文本源代码变为Abstract Syntax Tree (AST)
编译:
Chromes V8使用JIT编译,这意味着js代码的某些部分被转换为字节码(直接在您的处理器上运行,中间没有任何抽象层)。这提高了性能。有时它可能决定直接运行代码而不编译它,例如如果编译它需要的时间比实际运行它没有优化,所以没有任何好处。
评价:
代码已运行。
继续阅读: