JS基本解释
来源:互联网 发布:zard变声器数据 编辑:程序博客网 时间:2024/05/01 21:13
(一)基本了解
1.JS Variable命名规则用camel : 首字母单词小写。Function 用Pascal:首字母大写
2.Variable Scoping: 变量可访问范围。JS中只有 Gloable/Local.当不使用Var 定义时,会自动创建Gloable变量。
Nested Function :内部函数可以访问父类函数Var.
3.JS Function Expression: var addFun = function(x,y){return x+y;}; var c = addFun(5,6);
Typeof addFun - function.表达式右边是匿名函数
4.类型转换:Number(var) String(var). "+" 遇到string时自动变连字符.
5.JS中的Switch: switch(isNaN(VAR)){case 'One':break;}
6.|| 和&& 技巧:在一个判断式中 || 返回到第一个True , &&返回到第一个False
所以return Name || Age / Name&&Age. 当Name为空时候||返回Age.&&返回null
(二):对象
1.Array: var arr = new Array(); arr[index] = value;各种方法splice join indexOf pop push shift unshift......
(三)JS与DOM
1.SearchMethod 查找Element: getEelemenById, getElementByTagName, getElementByName
2.Event(事件!): 基于 PUB-SUB design pattern. 创建一个DOM(执行事件的主体)可以PUB Event .当DOM被使用时,可以SUB ,addEventHandler to sub to the Event
When event triggered,all the event subscribers are notified to excuting the evendhandler function.
事件顺序:Capturing 从外到内 #document->html->body->tag. Bubbling:从内到外
监听事件:addEventListener(事件名,执行函数,T/F(事件顺序))
var btn =document.getElementById('btnId');
btn.addEventListener('click',function( x ){ x },Flase);
- JS基本解释
- js页面基本代码解释
- iBatis基本配置解释
- html基本语法解释
- AS基本代码解释
- 堆栈基本解释
- HMTL5基本解释
- git基本命令解释
- JUnit注解基本解释
- JS错误代码解释大全
- JS错误代码解释大全
- JS错误代码解释大全
- JS错误代码解释大全
- JS错误代码解释大全
- js-onSelectStart解释
- Prototype.js 解释
- js prototype的解释
- JS命名空间解释
- 第一个Java程序
- 第十五章 编程练习
- [Leetcode] 18. 4Sum 解题报告
- JSF: parse JSON and add new Item
- 网上一篇非常好的讲socket的send和recv的
- JS基本解释
- Shell循环遍历每个元素都是变量的数组
- [Leetcode] 19. Remove Nth Node From End of List 解题报告
- How to get simple dispatch from this.props using connect w/ Redux?
- [Leetcode] 20. Valid Parentheses 解题报告
- Posix IPC
- Leetcode 213. House Robber II
- 看了数百个PPT封面,我只想告诉你这两个套路!
- 【Python】图片处理之“PIL”库简易安装笔记