//今天放假没看东西,贴上以前的基础,没事看着玩 // String->-> var myStr = "My name is LiuYashion";
console.log( myStr.length ); //
console.log( myStr.charAt() ); //M
console.log( myStr.charCodeAt() ); //77 (M)
console.log( myStr.indexOf("n") ); //
console.log( myStr.lastIndexOf("n") ); // console.log( String.fromCharCode() ); //M console.log( myStr.replace("My","His") ); //His name is LiuYashion 只能换一次,最前面的一个 console.log( myStr.substring(,) ); //LiuYashion,包含11,不包含21 console.log( myStr.toLowerCase() ); //my name is liuyashion
console.log( myStr.toUpperCase() ); //MY NAME IS LIUYASHION var myStr_1 = " My name is LiuYashion ";
console.log( myStr_1 ); // My name is LiuYashion
console.log( myStr_1.trim() ); //My name is LiuYashion // Number->-> var myArr = ["M","y"," ","n","a","m","e"," ","i","s"," ","L","i","u","Y","a","s","h","i","o","n"];
console.log( myArr.length ); //
console.log( myArr.indexOf("n") ); //
console.log( myArr.lastIndexOf("n") ); //20 // Math->-> console.log( Math.round(3.6) ); //4 四舍五入
console.log( Math.abs(-3.3) ); //3.3 绝对值
console.log( Math.ceil(-3.3) ); //-3 向上取整
console.log( Math.floor(-3.3) ); //-4 向下取整
console.log( Math.pow(,) ); //8 2的3次方
console.log( Math.sqrt() ); //3 9开方
console.log( Math.max(3.3,,) ); //30 最大值 // Date->->
var myDate = new Date('2016/3/21 23:11:11');
var nowDate = new Date(); //Wed Mar 23 2016 11:02:22 GMT+0800 (中国标准时间) console.log( nowDate.getFullYear() ); //2016 (number类型)
console.log( nowDate.getMonth() ); //2 月份是0-11
console.log( nowDate.getDate() ); //23 日期是从1开始 console.log( myDate.getDay() ); //1 星期一
console.log( myDate.getHours() ); //
console.log( myDate.getMinutes() ); //
console.log( myDate.getSeconds() ); // console.log( myDate.setFullYear() ); //1220886671000 距离1970.1.1的毫秒数.
console.log("-------------"+myDate)
console.log( myDate.setMonth() ); //1220886671000 距离1970.1.1的毫秒数
console.log( myDate.setDate() ); //1220886671000 距离1970.1.1的毫秒数 console.log( myDate ); //Mon Sep 08 2008 23:11:11 GMT+0800 (中国标准时间) var firstDate = new Date('2016/3/24 11:11:11');
var secondDate = new Date(); var spare = firstDate - secondDate; var spare_s = parseInt(spare/); // spare_s 总共的秒数
var spare_seconds = spare_s%; // spare_seconds 余下秒数 var spare_m = parseInt(spare_s/); // spare_m 总共分钟数
var spare_minutes = spare_m%; // spare_minutes 余下的分钟 var spare_h = parseInt(spare_m/); // spare_h 总共小时数
var spare_hours = spare_h%; // spare_hours 余下小时数 var spare_days = parseInt(spare_h/); // spare_days 总共的天数 console.log(spare_days+"天"+spare_hours+"小时"+spare_minutes+"分钟"+spare_seconds+"秒");
// 0天21小时18分钟15秒 var date_1 = new Date('1970/1/1');
console.log( Date.parse(date_1) ); //946656000000,距离1970.1.1的毫秒数 var my_date = new Date();
console.log( my_date.getFullYear()+"/"+ (my_date.getMonth()+) +"/"+ my_date.getDate() );
//2016/3/23