<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>无标题文档</title> <script>
/*
var i = 0;
i++;
if( i === 5 ){
i = 0;
}
i%=5;
*/
window.onload = function (){
var aLi = document.getElementsByTagName('li');
var arr = [ 'red', 'yellow', 'blue' ];
var str = '';
for( var i=0; i<aLi.length; i++ ){
aLi[i].index = i;
aLi[i].style.background = arr[i%arr.length];
aLi[i].onmouseover = function (){
this.style.background = 'gray';
};
aLi[i].onmouseout = function (){
this.style.background = arr[this.index%arr.length];
}; aLi[i].onmouseover = function (){
str = this.style.background; // 先存颜色
this.style.background = 'gray';
};
aLi[i].onmouseout = function (){
// this.style.background = arr[this.index%arr.length];
this.style.background = str;
}; aLi[i].checked = !aLi[i].checked; var a = 120<90 && 20;//前面不成立后面不执行
var b = 120<90 || 20>200;//前面成立后面不执行
var c = !!true;
var d = !200;//!可以取反,还可以进行数据类型转换,任何类型都可以转成boolean类型,
}
};
</script>
<style>
li { height:24px; margin-bottom:3px; list-style:none; }
</style>
</head>
<body>
</body>
</html>
<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>无标题文档</title> <script>
var str = 'js'; switch( str ){
case 'js' :
alert( 'js' ); break;
case 'html' :
alert( 'html' ); break;
default :
alert( str );
} 120<45 ? alert( '120<45' ) : alert( '120!<45' ); alert( 120<450? '120<450' : '120!<450' ); var i=0;
while (i<3){
alert(i);
i++;
} for(var i=0; i<6; i++){
if( i == 4 ){
// break; // 跳出
continue; // 跳过
}
alert(i);
} </script> </head> <body>
</body>
</html>
<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>无标题文档</title> <script>
/*
真假的问题:数据类型-数字(NaN)、字符串、布尔、函数、对象(element、[]、{}、null)、undefined
真:非0的数字(正负数字是真)、非空字符串(空格是真)、true、函数、能找到的元素、数组、json
假:0、NaN、空字符串''、false、不能找到的元素、null、undefined
*/
if( null ){
alert('真');
}else{
alert('假');
}
</script> </head> <body>
</body>
</html>

js---11运算符,流程控制,真假的更多相关文章

  1. JS基本数据类型&流程控制

    JS基本数据类型 number     -----  数值 boolean    -----  布尔值 string     -----  字符串 [x,y] -------数组 undefined  ...

  2. 12 (H5*) JS第二天 流程控制:顺序结构、分支结构、循环结构

    目录 1:一元运算符 2:流程控制 3:分支之if语句 4:分支之if-else语句 5:分支语句之三元运算符 6:if和else if语句 7:switch-case语句 8:while循环 9:d ...

  3. python的学习笔记01_3 基本运算符 流程控制if while 字符串常用办法

    基本运算符 运算符 计算机可以进行的运算有很多种,可不只加减乘除这么简单,运算按种类可分为算数运算.比较运算.逻辑运算.赋值运算.成员运算.身份运算.位运算,今天我们暂只学习算数运算.比较运算.逻辑运 ...

  4. day04 运算符 流程控制 (if while/of)

    1. 运算符算数运算符 + - * / int / float :数字类型 # print(10 + 3.1)# print(10 / 3)# print(10 // 3)# print(10 % 3 ...

  5. <基础> PHP 运算符 流程控制

    PHP运算符优先级: 递增/递减 (++ / --) > 算术运算符(+ .- .* ./) > 大小比较 > 逻辑与 (&)> 逻辑或(||) > 三目 > ...

  6. python - 用户交互/数据类型/格式化输出/运算符/流程控制单双多分支

    python:用户交互: 等用户输入,做反应: username=input("username:")password=input("password:")pr ...

  7. js数据类型转换 ----流程控制

    数据类型转换: //number转换成str // var str=a+''; // console.log(str); // console.log(typeof str); //转换成字符串了 v ...

  8. day52类型转换 运算符 流程控制

    0.复习 1.导入 <div id="div1" onclick="this.style.color = 'red';">12345</div ...

  9. 现代JS中的流程控制:详解Callbacks 、Promises 、Async/Await

    JavaScript经常声称是_异步_.那是什么意思?它如何影响发展?近年来这种方法有何变化? 请思考以下代码: result1 = doSomething1(); result2 = doSomet ...

  10. js 中的流程控制—while和do while

    while语句: while(exp){  }如果为true ,执行代码块里的语句,如果为false,跳出循环 <script> var i =1 ; while (i<10){ / ...

随机推荐

  1. Laravel-自定全局函数

    Laravel-自定全局函数 标签(空格分隔): php 习惯了 使用 ThinkPHP 框架,有一个公共方法类在代码编写上会快捷很多,所以有必要在此进行配置一番. 实现 在 app 创建文件夹 He ...

  2. java9新特性-21-java的动态编译器

    1. 官方Feature 243: Java-Level JVM Compiler Interface 295: Ahead-of-Time Compilation 2. 产生背景 Oracle 一直 ...

  3. Android项目实战(五十六):获取WebView加载的url的请求错误码

    例如需求,我有一个WebView 加载一个url, 该url对应的网页本身自带下拉刷新 ,但是网页本身会有出现400 500 等异常请求错误码 这时候网页加载失败,页面本身的下拉是无法使用的,要求重新 ...

  4. OpenGL编程(一)渲染一个指定颜色的背景窗口

    上次已经搭好了OpenGL编程的环境.已经成功运行了第一个程序.可只是照搬书上的代码,并没弄懂其中的原理.这次通过一个小程序来解释使用GLUT库编写OpenGL程序的过程. 程序的入口 与其他程序一样 ...

  5. SQL Server在用户自定义函数(UDF)中使用临时表

    SQL Server在用户自定义函数中UDF使用临时表,这是不允许的. 有时是为了某些特殊的场景, 我们可以这样的实现: CREATE TABLE #temp (id INT) GO INSERT I ...

  6. session 存入 redis

    <?php header('content-type:text/html;charset=utf-8'); /* * 更改 session 存储位置及存储方式. */ ini_set('sess ...

  7. 【ICM Technex 2018 and Codeforces Round #463 (Div. 1 + Div. 2, combined) A】 Palindromic Supersequence

    [链接] 我是链接,点我呀:) [题意] 在这里输入题意 [题解] 字符串倒着加到原串右边就好 [代码] #include <bits/stdc++.h> using namespace ...

  8. 【Henu ACM Round#19 B】 Luxurious Houses

    [链接] 我是链接,点我呀:) [题意] 在这里输入题意 [题解] 从右往左维护最大值. 看到比最大值小(或等于)的话.就递增到比最大值大1就好. [代码] #include <bits/std ...

  9. PatentTips - Virtualizing performance counters

    BACKGROUND Generally, the concept of virtualization in information processing systems allows multipl ...

  10. poj 1681 Painter&#39;s Problem(高斯消元)

    id=1681">http://poj.org/problem? id=1681 求最少经过的步数使得输入的矩阵全变为y. 思路:高斯消元求出自由变元.然后枚举自由变元,求出最优值. ...