1._proto_属性
每个对象都有一个内部属性_proto_,指向此对象的原型对象。通过这个内部属性,可以从实例对象中读取原型对象的属性。但是不是标准用法。
var a = {x:1}
var b = (_proto_:a)
b.x
//1
2.判断对象是否具有某个属性,使用hasOwnProperty方法。仅能判断对象本身的,继承的不能判断出来,返回false.
Date.hasOwnProperty('length');
3.jQuery解析json数据
下面引用的是官方API对$.getJSON()的说明:
jQuery.getJSON( url, [data,] [success(data, textStatus, jqXHR)] )
urlA string containing the URL to which the request is sent.
dataA map or string that is sent to the server with the request.
success(data, textStatus, jqXHR)A callback function that is executed if the request succeeds.
回调函数中接受三个参数,第一个书返回的数据,第二个是状态,第三个是jQuery的XMLHttpRequest,我们只使用到第一个参数。
$.each()是用来在回调函数中解析JSON数据的方法,下面是官方文档:
jQuery.each( collection, callback(indexInArray, valueOfElement) )
collectionThe object or array to iterate over.
callback(indexInArray, valueOfElement)The function that will be executed on every object.
$.each()方法接受两个参数,第一个是需要遍历的对象集合(JSON对象集合),第二个是用来遍历的方法,这个方法又接受两个参数,第一个是遍历的index,第二个是当前遍历的值
$.each(collection, callback(indexInArray, valueOfElement));
$.getJSON("info.json",function(data){
$("#info").html("");
$.each(data.comments, function(iIndex,item){
$("#info").append("<div>"+item.id+"</div>"+
"<div>"+item.nickname+"</div>"+
"<div>"+item.content+"</div>"
) ;
});
});
placeholder 属性提供可描述输入字段预期值的提示信息(hint)。
该提示会在输入字段为空时显示,并会在字段获得焦点时消失。
源文档 <http://www.w3school.com.cn/html5/att_input_placeholder.asp>
源文档 <http://www.cnblogs.com/codeplus/archive/2011/07/18/2109544.html>
源文档 <http://javascript.ruanyifeng.com/oop/inheritance.html>