【JS学習ノート】基本パッケージタイプ

2557 ワード

暁石のブログメールアドレス:[email protected]
転載は出所を明記してください。原文のリンク:http://blog.csdn.net/qiulanzhu/article/details/50663553
//    ,          
function box(obj){
	obj.name = "yi";
}

var big = new Object();
box(big);									//    ,          
document.write(big.name +"
"); //yi // // typeof // instanceof var type1 = [1,2,3,4,5]; document.write(type1 instanceof Array); var type2 = {}; document.write(type2 instanceof Object); var type3 = /g/; document.write(type3 instanceof RegExp); document.write("
"); /* */ //String、Boolean、Number // new , ( ), , 。 //Number document.write(Number.MAX_VALUE +"
"); document.write(Number.MIN_VALUE +"
"); //String //length,constructor,prototype //String var str = 'qiuyi'; document.write(str.charAt(1)); // document.write(str.charCodeAt(1)); // uicode document.write(str[1]); // ,ie var str1 = 'qiuyiis very activity!'; var str2 = 'good'; //concat document.write(str1.concat(str2) +'
'); //slice // document.write(str1.slice(2,4)); //[ 2, 4); document.write(str1.substring(2,4)); // document.write(str1.substr(2,4) +'
'); // 2 4 // document.write(str1.slice(-3)); // (str1.length-3 ) document.write(str1.substring(-1)); // document.write(str1.substr(-3)); // (str1.length-3 ) document.write(str1.slice(3,-1)); // document.write(str1.substring(3,-1) +'
'); // <0, 0, [0,3) document.write(str1.substr(3,-1)); //[0,3) var phone = 'my book is very nice!'; document.write(phone.indexOf('i')); // i document.write(phone.indexOf('i',9)); // , i document.write(phone.lastIndexOf('i')); // , i document.write(phone.lastIndexOf('i',10)); // //ps: , -1 // var desk = 'cat CAT dog DOG'; document.write(desk.toLowerCase()); document.write(desk.toUpperCase()); // ( ) var clothes = 'Mr.Qiu is Qiu'; document.write(clothes.match('is')); // document.write(clothes.search('is')); // indexOf document.write(clothes.replace('is', 'IS')); //IS is document.write(clothes.split(' ')); // // //fromCharCode(ascii); ascii //localeCompare(str1, str2);