<html>
<head>
<title>javascript基础</title>
</head>
<body>
1.流程控制 顺序 选择 循环结构<br/>
<script type="text/javascript">
var score = 50;
/* 多行注释
if ( score > 60 )
{
alert("恭喜,及格了...");
}
*/
// if ... else ... 单行注释
// if ... else if .... else if .... else ...
//switch
// ? : document.write("成绩是否合格 : " , score > 60 ? '及格':'没通过' ,"<br/>");
// while
// do while
//for( ; ;) break continue 之后的代码不执行 </script>
2.数组<br/>
<script type="text/javascript">
var a = new Array();//创建数组 没有长度 没有类型限制 set list
document.write("a数组的长度 : " , a.length ,"<br/>");
a[0] = 12;
a[1] = 5;
a[10] = 35;
a[2] = '张三';
a[5] = new Date();
document.write("a数组的长度 : " , a.length ,"<br/>");
document.write("a数组的元素 : " , a.toString() ,"<br/>"); var b = new Array(3);
document.write("b数组的长度 : " , b.length ,"<br/>");
b[5] = 100;
document.write("b数组的长度 : " , b.length ,"<br/>");
document.write("b数组的元素 : " , b ,"<br/>"); //a = new Array(5);
a.length = 5;//修改长度
document.write("a数组的元素 : " , a ,"<br/>");
//初始化
var colors = new Array('red','yellow','blue','green','white','black');
colors[6] = "gray";
document.write("colors数组的元素 : " , colors ,"<br/>");
/*
for(var i = 0; i < colors.length; i++ ) {
document.write(i , " : " , colors[i] ,"<br/>");
}
增强的for循环
for(var i in colors) {
document.write( i , " : " , colors[i] , "<br/>"); // i 数组索引
}
*/
var c = [, new Object , , 'a',new Number(80),"yema"];
c[0] = 20;
c[1] = 10;
c[2] = 30;
document.write("c是否是数组 : " , c instanceof Array , "<br/>");
document.write("c数组的元素 : " , c ,"<br/>");
</script>
3.数组的方法<br/>
<script type="text/javascript"> document.write("colors.concat(c) : " , colors.concat(c) ,"<br/>");
document.write("colors.join('->') : " , colors.join('->') ,"<br/>");
document.write("colors.pop() : " , colors.pop() ,"<br/>");
colors.push('abcd');
document.write("colors : " , colors ,"<br/>");
document.write("colors.shift() : " , colors.shift() ,"<br/>");
colors.unshift('oracle');
document.write("colors : " , colors ,"<br/>"); document.write("colors.reverse() : " , colors.reverse() ,"<br/>"); document.write("colors.sort() : " , colors.sort() ,"<br/>");
var d = [11,2,6,34]
document.write("d.sort() : " , d.sort() ,"<br/>"); document.write("colors.slice(2,5) : " , colors.slice(2,5) ,"<br/>");
document.write("======================== <br/>");
//splice
document.write("colors : " , colors ,"<br/>");
colors .splice(1,2);//删除
document.write("colors : " , colors ,"<br/>");
colors.splice(3,0,'java','xml');//添加
document.write("colors : " , colors ,"<br/>");
colors.splice(1,2,'football','swim');//修改
document.write("colors : " , colors ,"<br/>");
</script>
</body>
</html>

rs:

javascript 基础3第13节的更多相关文章

  1. 学习javascript基础知识系列第二节 - this用法

    通过一段代码学习javascript基础知识系列 第二节 - this用法 this是面向对象语言中的一个重要概念,在JAVA,C#等大型语言中,this固定指向运行时的当前对象.但是在javascr ...

  2. Android零基础入门第13节:Android Studio配置优化,打造开发利器

    原文:Android零基础入门第13节:Android Studio配置优化,打造开发利器 是不是很多同学已经有烦恼出现了?电脑配置已经很高了,但是每次运行Android程序的时候就很卡,而且每次安装 ...

  3. javascript 基础2第12节

    1. <html> <head> <title>javascript基础</title> </head> <body> 1.Nu ...

  4. javascript 基础1第11节

    <html> <head> <title>javascript基础</title> </head> <body> 1.NaN i ...

  5. Android零基础入门第29节:善用TableLayout表格布局,事半功倍

    原文:Android零基础入门第29节:善用TableLayout表格布局,事半功倍 前面学习了线性布局和相对布局,线性布局虽然方便,但如果遇到控件需要排列整齐的情况就很难达到要求,用相对布局又比较麻 ...

  6. Android零基础入门第30节:两分钟掌握FrameLayout帧布局

    原文:Android零基础入门第30节:两分钟掌握FrameLayout帧布局 前面学习了线性布局.相对布局.表格布局,那么本期来学习第四种布局--FrameLayout帧布局. 一.认识FrameL ...

  7. Android零基础入门第28节:轻松掌握RelativeLayout相对布局

    原文:Android零基础入门第28节:轻松掌握RelativeLayout相对布局 在前面三期中我们对LinearLayout进行了详细的解析,LinearLayout也是我们用的比较多的一个布局. ...

  8. Android零基础入门第26节:layout_gravity和gravity大不同

    原文:Android零基础入门第26节:layout_gravity和gravity大不同 上一期我们一起学习了LinearLayout线性布局的方向.填充模型和权重,本期来一起学习LinearLay ...

  9. Android零基础入门第27节:正确使用padding和margin

    原文:Android零基础入门第27节:正确使用padding和margin 前面两期我们学习了LinearLayout线性布局的方向.填充模型.权重和对齐,那么本期我们来学习LinearLayout ...

随机推荐

  1. PC-如何禁用 Cookie

    \w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)* if (string.IsNullOrEmpty(TextBox2.Text) || TextBox2.Tex ...

  2. eas bos 编辑界面 editUIt 属性值为空

    在编辑界面,我们可以正常的保存某个值到数据库,同时列表界面也可以正常显示. 但是当我们再次打开这个编辑界面的时候,该属性值缺无法显示. 通常情况下,通过下面两个方法可以解决 方法一: 在编辑界面重写一 ...

  3. oc学习之路----QQ聊天界面

    用到的技术:自定义cell,通知机制,代理模式 transform 1.自定义cell(通过代码自定义cell) ①首先新建一个类继承UITableViewCell ②重写initWithStyle: ...

  4. 【python自动化第八篇:网络编程】

    一.拾遗 动态导入模块 目的是为了在导入模块的过程中将模块以字符的格式导入. #!/usr/bin/env python # -*- coding:utf-8 -*- #Author:wanghui ...

  5. MINA之心跳协议运用

    转自:http://my.oschina.net/yjwxh/blog/174633 摘要 心跳协议,对基于CS模式的系统开发来说是一种比较常见与有效的连接检测方式,最近在用MINA框架,原本自己写了 ...

  6. 【JAVA - SSM】之MyBatis动态SQL

    动态SQL就是在SQL语句中添加一些标签,以完成某些逻辑.通常用到的动态SQL标签有<if>.<choose>.<where>.<trim>.<s ...

  7. [置顶] linux 解压版安装

    1:下载mysql解压版包去官网下载www.mysq.com 下载.下载linux通用版本就好了 2.基本配置 首先,我们准备好Linux环境,我们使用CentOS 5.8进行试验安装.第一步,我们需 ...

  8. Linux下Join命令

    Linux下Join命令 最近新上线算法,打算分析起点书籍点击率的波动,原来已经有流程每天每本书籍的点击率数据(文件).之前这种情况都是写代码对不同天的进行合并,后来发现linux下直接就有join命 ...

  9. spring mvc Spring Data Redis RedisTemplate [转]

    http://maven.springframework.org/release/org/springframework/data/spring-data-redis/(spring-data包下载) ...

  10. uva340 数字匹配检索问题

    这道题目大意是:给定一个secret code,然后输入guess code,让你编程给出提示,提示的格式是(i,j),其中i表示strong match的个数,j表示weak match的个数.所谓 ...