JavaScript高级程序设计总结二

第六章 面向程序设计

  1.JavaScript支持OO 面向对象编程、

          所有引用类型(函数,数组,对象)都拥有__proto__属性(隐式原型)

          所有函数拥有prototype属性(显式原型)(仅限函数)

          原型对象:拥有prototype属性的对象,在定义函数时就被创建

  2.创建对象

  • 工厂模式
  • 构造函数模式

 

//创建构造函数
        function Word(words){
            this.words = words;
        }
        Word.prototype = {
            alert(){
                alert(this.words);
            }
        }
        //创建实例
        var w = new Word("hello world");
        w.print = function(){
            console.log(this.words);
            console.log(this);  //Person对象
        }
        w.print();  //hello world
        w.alert();  //hello world

 

  • 原型模式

  3.原型链的继承  prototype  construcor 

 

第七章 函数表达式

  1.定义函数的方式

  • 函数声明 function a () {}   函数声明提升
  • 函数表达式  var a = funtion () {}  匿名函数 拉姆达函数

2.递归

  递归函数是在一个函数通过名字调用自身的情况下构成的  但是建议使用 arguments.callee()

3.闭包

  闭包是有权访问另一个函数作用域中的变量的函数

4.通常函数的作用域及其所有变量都会在函数执行结束后被销毁

第八章  BOM

1.window 对象

  • BOM的核心对象是window 他表示浏览器的一个实例  同时又是ECMAscript中的 global 对象
  • 窗口位置  window.screenLeft (window.screenX)  window.screenTop (window.screenY )
  • 窗口大小  innerWidth innerHeight 视窗大小  outerHeight outerWidth 浏览器窗口大小
  • 兼容模式 和 IE8混杂模式  document.documentElement.clientWidth document.documentElement.clientHeight  document.body.clientWidth  document.body.clientWidth 
  • window.open() 打开一个新的页面
  • window.close()  仅仅适用于 open()打开的窗口
  • 间歇调用  和 超时调用  setTimeout()  setInterval()
  • 系统对话框 alert()  confirm()  prompt()

2.location方法

  • location.href  == location.toString()  当前加载页面的完成URL
  • location.hash 返回URL中的hash
  • location.host 返回服务器名称和端口号
  • location.hastname  返回不带端口号的服务器名称
  • location.path 返回url中的目录和文件名称
  • location.port 返回端口号
  • location.protocol 返回URL使用的协议
  • location.search 返回url中的参数
  • location.reload()  重新加载页面   加参数 true 表示 所有资源完成重新加载

3.navigator对象

  • navigator.appCodeName 浏览器名称
  • navigator.appName  完成的浏览器名称
  • navigator.appVersion 浏览器的版本
  • navigator.platform 操作系统平台
  • navigator.userAgent 浏览器的用户代理

4.screen 对象

5.history对象

  • history.go()
  • histtory.back()
  • histtory.forward()

第九章: 客户端检测 

 略

第十章

1.节点层次

  Document > Element  >Element > Element > text

2.操作节点

  appendChild()  insertBefore()  replaceChild()  removeChild()   cloneNode(true)深度克隆

3.document类型

  •  document.URL ()  取得完整的URL    document.domain() 取得完整的域名  document.referrer()  取得来源页面的URL 
  • 查找方法  document.getElementById()   document.getElementsByTagName()  document.getElementsByClassName()  

4.HTML元素

  • 取得特性  el.getAttribute()   设置特性  el.setAttribute()   创建元素 document.creatElement()

5.Text类型

   creatTextNode()  创建文本节点

第十一章DOM扩展

1、选择符API

    Selectors APILevel1 的核心是两个方法:querySelector()和querySeletorAll()

2、元素遍历      Element Traversal API为DOM元素添加了一下5个属性

  1. childElementCount:返回子元素(不包含文本节点和注释)的个数
  2. firstElementChild:指向第一个子元素
  3. lastElementChild:指向最后一个子元素
  4. previousElementSibling:指向前一个同辈元素
  5. nextElementSibling:指向后一个同辈元素

3、自定义数据属性

      HTML5规定可以为元素添加非标准的属性,但要添加前缀data-,目的是为元素提供与渲染无关的信息,或者提供语义信息。这些属性可以任意添加、随便命名,只要以data-开头即可。添加了自定义属性后,可以通过元素的dataset属性来访问自定义属性的值。   

4、DOM2样式属性和方法

  1. cssText:通过他能访问到style特性中的css代码
  2. length:应用给元素的css属性的数量
  3. getPropertyCSSValue(propertyName):返回包含给定属性值的CSSValue对象
  4. getPropertyPriority(propertyName):如果给定的属性使用了 !important设置,则返回”important”,否则,返回空字符串
  5. getPropertyValue(propertyName):返回给定属性的字符串值
  6. item(index):返回给定位置的css属性的名称
  7. removeProperty(propertyName):从样式中删除给定属性
  8. setProperty(propertyName,value,priority):将给定属性设置为相应的值,并加上优先权标志(”important”或者一个空字符串)
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值