2018.4.21
字符串
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>字符串</title>
</head>
<body>
<script type="text/javascript">
function stringTest() {
var str = "字符串是个啥";
var subString = str.substring(2,4);
console.log("subString:"+subString);
var urlStr = "wdadadeadaedadafeegw-v.vmwoi";
var arrays = urlStr.split("e");
console.log(arrays);
for (var i = 0; i< arrays.length; i++) {
if(arrays[i].indexOf("ada") == 0){
console.log(arrays[i].substring(arrays[i].indexOf("=")+1))
}
}
arrays.forEach(function(item) {
console.log("aaa"+item);
});
}
stringTest();
</script>
</body>
</html>
结果:
[Web浏览器] "subString:串是" /day30/04-js-string.html (13)
[Web浏览器] "wdadad,ada,dadaf,,gw-v.vmwoi" /day30/04-js-string.html (16)
[Web浏览器] "ada" /day30/04-js-string.html (21)
[Web浏览器] "aaawdadad" /day30/04-js-string.html (27)
[Web浏览器] "aaaada" /day30/04-js-string.html (27)
[Web浏览器] "aaadadaf" /day30/04-js-string.html (27)
[Web浏览器] "aaa" /day30/04-js-string.html (27)
[Web浏览器] "aaagw-v.vmwoi" /day30/04-js-string.html (27)
数组
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>数组的定义</title>
</head>
<body>
<script type="text/javascript">
var arrays = new Array();
arrays[0]="云姨";
arrays[1]="云婶";
arrays[2]="云大娘";
for(var i = 0; i<arrays.length;i++) {
console.log(arrays[i]);
}
arrays.forEach(function(item) {
console.log(item);
});
var doubleArray = [["污云","赋赋","老付"],["大飞","我党","翘臀"]];
for (var i= 0;i<2;i++){
for(var j = 0;j<3;j++){
console.log(doubleArray[i][j]);
}
}
doubleArray.forEach(function(arr) {
arr.forEach(function(item){
console.log("---->"+item);
});
});
</script>
</body>
</html>
结果:
[Web浏览器] "云姨" /day30/07-js-array.html (15)
[Web浏览器] "云婶" /day30/07-js-array.html (15)
[Web浏览器] "云大娘" /day30/07-js-array.html (15)
[Web浏览器] "云姨" /day30/07-js-array.html (19)
[Web浏览器] "云婶" /day30/07-js-array.html (19)
[Web浏览器] "云大娘" /day30/07-js-array.html (19)
[Web浏览器] "污云" /day30/07-js-array.html (27)
[Web浏览器] "赋赋" /day30/07-js-array.html (27)
[Web浏览器] "老付" /day30/07-js-array.html (27)
[Web浏览器] "大飞" /day30/07-js-array.html (27)
[Web浏览器] "我党" /day30/07-js-array.html (27)
[Web浏览器] "翘臀" /day30/07-js-array.html (27)
[Web浏览器] "---->污云" /day30/07-js-array.html (34)
[Web浏览器] "---->赋赋" /day30/07-js-array.html (34)
[Web浏览器] "---->老付" /day30/07-js-array.html (34)
[Web浏览器] "---->大飞" /day30/07-js-array.html (34)
[Web浏览器] "---->我党" /day30/07-js-array.html (34)
[Web浏览器] "---->翘臀" /day30/07-js-array.html (34)