一些Java面试题
2017-05-15 14:42
387 查看
1. JavaScript语言中的基本类型有哪些?
(1)number:包括正数、负数、小数
(2)string
(3)boolean:有true或false
**住:**JS中的数据类型
(1)基本数据类型
(2)复合数据类型:函数、对象、数组
(3)null、undefined
2. 写出JavaScript在IE和FireFox浏览器中的一些差异(至少写3条)
(1)添加事件
IE:element.attachEvent(”onclick”, func);。
FF:element.addEventListener(”click”, func, true)。
通用:element.onclick=func。虽然都可以使用onclick事件,但是onclick和上面两种方法的效果是不一样的,onclick只有执行一个过程,而attachEvent和addEventListener执行的是一个过程列表,也就是多个过程。例如:element.attachEvent(”onclick”, func1);element.attachEvent(”onclick”, func2)这样func1和func2都会被执行。
(2)标签的自定义属性
IE:如果给标签div1定义了一个属性value,可以div1.value和div1[“value”]取得该值。
FF:不能用div1.value和div1[“value”]取。
通用:div1.getAttribute(”value”)。
(3)父节点、子节点和删除节点
IE:parentElement、parement.children,element.romoveNode(true)。
FF:parentNode、parentNode.childNodes,node.parentNode.removeChild(node)。
(4)获取窗体的高度和宽度
IE:document.body.offsetWidth和document.body.offsetHeight。注意:此时页面一定要有body标签。
FF:window.innerWidth和window.innerHegiht,以及document.documentElement.clientWidth和document.documentElement.clientHeight。
通用:document.body.clientWidth和document.body.clientHeight。
5. JavaScript编程题:写一个Student类继承Person类的例子。对应的类图如下:
JS继承方式:对象冒充
(1)number:包括正数、负数、小数
(2)string
(3)boolean:有true或false
**住:**JS中的数据类型
(1)基本数据类型
(2)复合数据类型:函数、对象、数组
(3)null、undefined
2. 写出JavaScript在IE和FireFox浏览器中的一些差异(至少写3条)
(1)添加事件
IE:element.attachEvent(”onclick”, func);。
FF:element.addEventListener(”click”, func, true)。
通用:element.onclick=func。虽然都可以使用onclick事件,但是onclick和上面两种方法的效果是不一样的,onclick只有执行一个过程,而attachEvent和addEventListener执行的是一个过程列表,也就是多个过程。例如:element.attachEvent(”onclick”, func1);element.attachEvent(”onclick”, func2)这样func1和func2都会被执行。
(2)标签的自定义属性
IE:如果给标签div1定义了一个属性value,可以div1.value和div1[“value”]取得该值。
FF:不能用div1.value和div1[“value”]取。
通用:div1.getAttribute(”value”)。
(3)父节点、子节点和删除节点
IE:parentElement、parement.children,element.romoveNode(true)。
FF:parentNode、parentNode.childNodes,node.parentNode.removeChild(node)。
(4)获取窗体的高度和宽度
IE:document.body.offsetWidth和document.body.offsetHeight。注意:此时页面一定要有body标签。
FF:window.innerWidth和window.innerHegiht,以及document.documentElement.clientWidth和document.documentElement.clientHeight。
通用:document.body.clientWidth和document.body.clientHeight。
5. JavaScript编程题:写一个Student类继承Person类的例子。对应的类图如下:
JS继承方式:对象冒充
/** *JS继承方式:对象冒充 */ function Person(age, name){ this.age = age; this.name = name; this.sayHello = function(){ } } function Student(score, age, name){ this.newMethod = Person; this.newMethod(age, name); delete this.newMethod; this.score = score; this.sayScore = function(){ } } /** *call */ function Person(age, name){ this.age = age; this.name = name; this.sayHello = function(){ } } function Student(score, age, name){ Person.call(this, age, name); this.score = score; this.sayScore = function(){ } } /** *apply *可以把Student的整个arguments对象作为第二个参数传递给apply方法 *当然,只有超类中的参数顺序与子类中的参数顺序完全一致才可以传递参数对象。 *如果不是,就必须创建一个单独的数组,按照正确的顺序放置参数。此外,还可使用call方法。 */ function Person(age, name){ this.age = age; this.name = name; this.sayHello = function(){ } } function Student(score, age, name){ Person.apply(this, age, name); this.score = score; this.sayScore = function(){ } }
相关文章推荐
- 一些面试题(JAVA)
- 一些JAVAbs面试题
- Java常见面试题(一)一些零碎的知识点
- JAVA的程序代码小细节,变量的使用,以及一些细节的面试题
- Java 关于线程的一些面试题
- 在网上找的一些java面试题,特经典
- 一些JAVA面试题和答案(偶尔更新)
- java一些基础面试题总结(转自黑马论坛)
- 面试Java实习生时的一些面试题
- java面试题 内部类的一些特性
- 网上的一些java面试题整理
- 整理一些常见的java及android面试题(2)
- 整理一些常见的java及android面试题(1)
- java 异常基础知识以及一些面试题讲解
- 一些Java面试题深入分析
- 收集的一些JAVA面试题,与大家分享
- 网上搜集整理的一些java基础面试题
- java基础中一些值得聊的话题(可以当做面试题)
- Java中的集合类解析和一些有深入的面试题
- 集合类 Java中的集合类解析和一些有深入的面试题