day 12
var str = “hgDzGHjhcxghvcgxzhjzcgjhxzgcjhgsduyfuys”;
var obj = {};
var arr = [];
var letter;
for(var i = 0,len = str.length;i<len;i++){
letter = str[i];
if(!obj[letter]){ // 第一次放进去
obj[letter] = 1;
}else{
obj[letter]++;
}
}
var max_key,max_num=0;
for(key in obj){
if(max_num <obj[key]){
max_num = obj[key];
max_key = key;
}
}
alert('弹出:'+max_key);
function Animal(wight, color) {
this.wight = wight;
this.color = color;
}
Animal.prototype.eat = function() {
console.log("吃");
}
//Cat的构造函数
function Cat( /*weight, color, */ sex) {
// this.weight = weight;
// this.color = color;
this.sex = sex;
}
// Cat.prototype.eat = function() {
// console.log("猫吃");
// }
//改变cat的原型指向,指向Animal,这时Animal和Cat就有关系了
Cat.prototype = new Animal(100, "red");
Cat.prototype.catch = function() {
console.log("抓老鼠");
}
var cat = new Cat("男");
console.log(cat.wight);
console.log(cat.color);
console.log(cat.sex);
#leftDiv,#rightDiv{
width: 200px;
height: 200px;
}
#leftDiv{
background: #16A05D;
float: left;
}
#rightDiv{
background: #DC5044;
float: right;
}
#centerDiv{
background: #FFCD41;
height: 200px;
margin: 0 200px;
}
<body>
<div id="leftDiv">左边div</div>
<div id="rightDiv">右边div</div>
<div id="centerDiv">中间div</div>
</body>
$.extend({
sayHello: function(name) {
console.log('Hello,' + (name ? name : 'Dude') + '!');
}
})
$.sayHello(); //调用
$.sayHello('test'); //带参调用

浙公网安备 33010602011771号