设置+获取 cookie
// 设置和获取cookie
// 把三个可选参数 放在options里。因为domain、path非必要的情况下不传,而expires的传的频率又比较高
function cookie( name , value , options){
// if参数大于一个且value 是一个字符串 ->那么我们认为此时我们在设置cookie
if( arguments.length > 1 && typeof value === "string"){
// 1.设置cookie
// 让options不传参数的时候也是一个对象
if(!isObject( options )){
options = {
};
}
// 如果 expires 传了的话
if( typeof options.expires === "number"){
// expires 参数的单位为天
var d = new Date();
d.setDate( d.getDate() + options.expires );
}