我试着检查es6中的"变量"是否是常量:
const a = 1;
function test() {
try {
a = 2;// throws an error
} catch (error) {
console.log(error)
}
}
test();
Run Code Online (Sandbox Code Playgroud)
但是当我使用eval()函数时,它不会抛出错误.
const a = 1;
function test() {
try {
eval("a = 2;")// not throws an error
} catch (error) {
console.log(error)
}
}
test();
Run Code Online (Sandbox Code Playgroud)
并且我使常量局部,函数eval确实抛出了预期的错误.
function test() {
try {
const a = 1;
eval("a = 2;")//throws an error
} catch (error) {
console.log(error)
}
}
test();
Run Code Online (Sandbox Code Playgroud)
当我使用函数eval()导致它不会像预期的那样抛出错误.functoin eval()在这里做了什么?我在Node v6.2.2中运行它
const …Run Code Online (Sandbox Code Playgroud) 在ubuntu中安装mysql时apt-get install mysql-server,会在安装过程中询问mysql用户名和密码.
但是当使用dockerfile构建mysql映像时,如何提供用户名和密码?
我尝试使用dockerfile如下:
FROM ubuntu:14.04
apt-get update
apt-get install -y mysql-server
Run Code Online (Sandbox Code Playgroud)
但是在构建映像时,我发现我们可以在没有用户名和密码的情况下登录mysql.
当我使用dockerfile构建我的图像时,如何设置用户名和密码?