zoukankan      html  css  js  c++  java
  • JS学习

          阅读目录:

    • 1. 属性、方法、JS数据类型
    • 2. 
    • 3. 
    • 4. 
    • 5. 
    • 6. 
    • 7. 

    一、创建对象

    1、通过nwe关键字创建对象
    var obj = new Object();
    
    2、对象字面量
    1)简单字面量
    

    var obj = {};
    obj.name='测试';
    obj.test = function(){
    return this.name;
    };

    2)嵌套字面量
    var obj = {
    name:'测试',
    test:function(){
    console.log(this.name);
    }
    };
    obj.test(); 函数申明和函数表达式
    function test (){} var test = function(){} 3、构造函数(首字母必须大写) function Test(name,age){ this.name =name, this.age = age, this.todo = function(){ return this.name; } } var test = new Test('test',22);//实例化 test.todo();

    javascript 六种数据类型:object、number、boolen、undefined、null、string,其中null代表“空值”,undefined表示声明了一个变量未初始化时,得到的就是undefined

  • 相关阅读:
    mouseenter和mouseleave,mouseover和mouseout
    哈哈哈
    instanceof与typeof
    js事件传参
    浮动与清除问题
    简易富文本编辑
    js之prototype
    json序列化
    我对Defer and Promise的实现
    Ajax 完整教程
  • 原文地址:https://www.cnblogs.com/macT/p/9328592.html
Copyright © 2011-2022 走看看