document.querySelector("input").οnkeydοwn=function(){
console.log("1");
}
var fun=function(){
console.log(2);
}
document.querySelector("input").addEventListener("click",fun);
document.querySelector("input").removeEventListener("click",fun);
$(document).ready(function(){
console.log("文档加载完毕")
})
$(function(){
console.log("文档加载完毕")
})
window.οnlοad=function(){
console.log("文档加载完毕")
}
document.querySelector("input").οnkeydοwn=function(event){
console.log("键盘按下");
}
var lastTime = 0;
document.querySelector(".btn").onclick = function (event) {
var nowTime = event.timeStamp;
if (nowTime - lastTime > 1000 || lastTime === 0) {
lastTime = nowTime;
console.log("111");
}
}
document.querySelector(".btn").onclick = function () {
document.querySelector(".box").style.backgroundColor = "red";
document.querySelector(".box").style["background-color"] = "red";
document.querySelector(".box").setAttribute("title", "wosh");
document.querySelector(".box").innerText = "aaa";
document.querySelector(".box").innerHTML = "aaa";
console.log(document.querySelector(".box").innerText);
console.log(document.querySelector(".box").innerHTML);
}
- 222
var ul = document.querySelector("ul")
var oldLi = document.querySelector("li");
var newLi = document.createElement("li")
newLi.innerText = "111"
ul.insertBefore(newLi, oldLi);
var a = 10;
function fun() {
console.log(this.a);
}
var obj = {
a: 100
};
var obj1 = {
a: 200
};
var newFun = fun.bind(obj);
console.log(newFun);
obj1.fun = newFun;
obj1.fun();
var arr = [1, 123, 124, 12, 3, 235, 23, 65, 52, 35, 246];
// max 函数操作的时候 没有用到 this 所以无论是什么都可以
var maxNum = Math.max.apply(null, arr);
console.log(maxNum);
fun();
x();
function fun(){
console.log("1");
}
var x = function(){
console.log("2");
}
function fun() {
var sum = 0;
for (var i = 0; i < arguments.length; i++) {
sum += arguments[i];
}
console.log(sum);
}
fun(1, 2, 3);
(function (){
console.log("1");
})();
function CreatCat(name, age) {
this.name = name;
this.age = age;
}
CreatCat.prototype.say=function(){
console.log(this.name)
}
var cat1 = new CreatCat("咪咪", 1)
console.log(cat1);
cat1.say();
console.log(cat1.constructor);
function User(name, age) {
this.name = name;
this.age = age;
}
User.prototype.say = function () {
console.log("猫")
}
var user1 = new User("张三", 18)
console.log(user1);
function SystemUser(username, userage) {
User.call(this, username, userage);
}
Object.assign(SystemUser.prototype, User.prototype);
var systemuser1 = new SystemUser("李四", 23)
console.log(systemuser1);
SystemUser.prototype.sayHi = function () {
console.log('我是管理员')
}
systemuser1.sayHi();
user1.sayHi();//提示错误
var obj = { name: '哈哈哈', a: 'hello', age: 20 }
var obj1 = { age: 0 }
for (var key in obj) {
// key 代表属性名
// 当对象的属性名存在了一个变量内 想要访问属性值 obj[变量]
// console.log(obj[key])
obj1[key] = obj[key]
}
console.log(obj1);
var obj = { name: '哈哈哈', a: 'hello', age: 20 }
var keys = Object.keys(obj);
console.log(keys);
var obj1 = { age: 0 }
for (var i = 0; i < keys.length; i++) {
obj1[keys[i]] = obj[keys[i]]
}
console.log(obj1);
var obj1 = { age: 20 }
var obj2 = { name: '哈哈哈' }
var obj3 = { say: 'hello' }
var obj = { ...obj1, ...obj2, ...obj3 }
console.log(obj);
function Animal(type) {
this.type = type;
}
Animal.prototype.say = function () {
console.log("我是" + this.type + "动物");
}
var catAnimal = new Animal("猫科类");
console.log(catAnimal);
catAnimal.say();
function Cat(name, age) {
this.name = name
this.age = age
}
Cat.prototype = catAnimal
var mimi = new Cat('小花儿', 2)
mimi.say()
function fun(){
var num = 10;
function fun1(){
num++;
console.log(num)
}
return fun1;
}
var newFun=fun();
newfun();
newfun();
newfun();
fun=null;
newFun=null;