Html 编码规范css
Css 编码规范html
Position:absolute; display: none; overflow: hidden; float: left; clear: both; width:960px; height: 300px; margin: 0; padding: 0; border: 1px solid #ccc; background: #ccc; font-family: “verdaba” ; font-size: 12px; font-weight: bold; color: #555; text-decoration: underline; line-height: 22px; text-align: left; vartical-align: baseline; direction: ltr; z-index: 3;数组
Js 编码规范函数
window.onload = function() {布局
addBtn.onclick = function() {性能
createEle();编码
};spa
removeBtn.onclick = function() {htm
var box = document.getElementById("boxcon");对象
removeEle(box.lastChild);
};
}
(5)for循环与左括号之间"(" 之间有空格;例如:
for (var i = 0; i < obj.length; i++) {
//代码块
}
Fo r
注释:每一个方法都要有必定的注释,且写在函数上面,函数内部的变量的注释 可写在后面。
字面量:建立 数组,对象,等均可以用字面量来建立。
例如:建立数组 var newArray = ["ab", "vdf"];
建立对象 var newObj = {
prop1:value1,
prop2:value2,
..
};
(6)在for循环相似这样的代码时, for (var I = 0; I < array.lenth; i++) {} 能够把 对象的长度 保存到变量里,这样就不用每次循环都要计算一下长度 能够提升性能。
var arrAlength = array.length;
for (var I = 0; I < arrAlength; i++) {}
(7)字符串 首选用单引号 ‘’; 必要的时候用双引号””;