标签:一个 冻结 conf charset pre nbsp oca str ble
冻结: 即密封,又禁止修改所有属性值!
何时: 如果一个对象中保存了大量不变的属性值时
Object.freeze(obj);
其实是将所有属性的writable设置为false!
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
</head>
<body>
<script>
"use strict";
var config={
host:"localhost",
port:"27017",
db:"test",
uname:"root",
pwd:"root"
}
Object.freeze(config);
config.host="192.168.0.100";
</script>
</body>
</html>
标签:一个 冻结 conf charset pre nbsp oca str ble
原文地址:https://www.cnblogs.com/sske531549304/p/9386110.html