当前位置: 首页 > news >正文

用PS做网站搜索框网站建设怎么弄

用PS做网站搜索框,网站建设怎么弄,建设网站你认为需要注意,广州优化网站关键词【三】运算符 【1】算数运算符 (1)分类 加减乘除:*/取余:%和python不一样的点:没有取整// (2)特殊的点 只要NaN参与运算得到的结果也是NaNnull转换成0,undefined转换成NaN 【2…

【三】运算符

【1】算数运算符

(1)分类

  • 加减乘除:±*/
  • 取余:%
  • 和python不一样的点:没有取整//

(2)特殊的点

  • 只要NaN参与运算得到的结果也是NaN
  • null转换成0,undefined转换成NaN

【2】比较运算符

(1)分类

  • 大于等于小于:>=<
  • 相等不相等:== !==
  • 大于等于小于等于:>= <=

(2)特殊

2.1强相等
  • 强相等:===
  • 弱相等(类型自动转换):==
"1" == 1	//true
"1" === 1	//false
2.2null
null == 0	//false
null === 0	//false
null >= 0 	//true
null <= 0 //true
null==undefined	//true
null===undefined	//false
2.3NaN
  • 检查一个值是否为非数字
NaN == NaN //false
isNaN(NaN) //true
isNaN() //true
isNaN(undefined) //true
isNaN(Infinity) // false
isNaN("bruce") // true
NaN == 'bruce'//false
2.4Infinity
  • 检查一个值是否为有限数
Infinity == Infinity // true
isFinite(Infinity) // false
isFinite(10) // true

【3】逻辑运算符

(1)分类

  • 与&&
  • 或||
  • 非!

(2)示例

5 && 'a' && 12.1 	//12.1
0 || null || "a"	//'a'

【4】赋值运算符

(1)分类

  • = 等于
  • += 加等于
  • -= 减等于
  • *= 乘等于
  • /= 除等于
  • %= 取余等于
  • ++ 递加
  • – 递减

【5】一元运算符

  • 和c或c++等语言一样
  • python中没有

(1)i++、i–

  • 先赋值再计算
var a = 100;
var b = a++;	//100
var c = a++;	//101
console.log(a)	//102

(2)++i、–i

  • 先计算再赋值
var a = 100;
var b = --a;	//99
var c = --a;	//98
console.log(a);	//98

【6】运算优先级

  • 从高到低

  • () -> 一元 -> 算数 -> 比较 -> 逻辑 -> 赋值

【四】流程控制语句

【1】if else

(1)语法

  • 习惯性缩进,可以不
if (condition) {do something}
else if (condition){do something}
...
else {do something
}

(2)示例

var identify = 'normal';
if (identify == 'super'){console.log('hello super')}
else if (identify == 'admin'){console.log('hello admin')}
else {console.log('hello normal')
};

【2】switch case

(1)语法

  • 注意:必须写break
    • 否则再满足当前条件的情况下还会继续执行其他条件判断
switch (variable) {case value1:do somethingbreak;case value1:do somethingbreak;...    default:do somethingbreak
};

(2)示例

var identify = 'normal';
switch (identify) {case 'super':console.log('hello super');break;case 'admin':console.log('hello admin')break;default:console.log('hello normal')break
};

【3】for

(1)语法

for (初始化表达式; 条件表达式; 更新表达式) {do something;
};

(2)示例

var array = [11, 22, 33]
for (var i = 0; i < array.length; i++) {console.log(i, array[i]);
};
//0 11
//1 22
//2 33
  • 可以和pythonfor i in range很像
    • 但是i确实索引,或者键值
var array = [11, 22, 33]
for (var i in array) {console.log(i, array[i]);
};
//0 11
//1 22
//2 33
  • for of 作用和python的for in一样
var array = [11, 22, 33];
for (var i of array) {console.log(i);
};
//11
//22
//33

【4】while

(1)语法1

while condition {do something;
};

(2)语法2

do {do something;
}while (condition);

(3)示例

  • 两种语法的区别:先判断还是先执行
var i = 0;
while (i++ < 3) {console.log(i);
};
//1
//2
//3
var i = 0;
do {console.log(i);
}while (i++ < 3);
//0
//1
//2
//3

【5】三元运算符号

  • 和c语言一样,和python不一样
    • python:true if contion else fale

(1)语法

condition ? true : false

(2)示例

var flag = 1
var indetify = flag == 0 ? "super" : "admin"
var flag = 2;
var indentify = flag == 0 ? "super" : flag == 1 ? "admin" : "normal"; 
# python中
flag = 2
identify = "super" if flag == 0 else "admin" if flag ==1 else "normal"
print(identify)

【五】数组

  • 它是一种有序集合,可以通过索引访问和操作其中的元素。

【1】定义数组

var array = [];
var array = new Array();

【2】查看类型

typeof array;
//'object'

【3】常用方法

(1)元素个数

  • .length
var array = [11, 22, 33];
array.length;	//3

(2)遍历

  • for of和python的for in作用一样
var array = [11, 22, 33];
for (var i of array) {console.log(i);
};
//11
//22
//33
  • .forEach():
    • forEach 方法接受一个回调函数作为参数,该回调函数将在数组的每个元素上被调用。
    • 回调函数接受三个参数:当前元素的值、当前元素的索引和正在遍历的数组本身。
//一个参数
var array = [11, 22, 33];
array.forEach(function(value) {console.log(value);            
});
//11
//22
//33
//两个参数
var array = [11, 22];
array.forEach(function(value, index) {console.log(value, index);
});
//11 0
//22 1
//三个参数
var array = [11, 22];
array.forEach(function(value, index, element) {console.log(value, index, array);
});
//11 0 (2) [11, 22]
//22 1 (2) [11, 22]
//函数另一种写法
var array = [11, 22];
array.forEach((value, index, array) => {console.log(value, index, array);
});
//11 0 (2) [11, 22]
//22 1 (2) [11, 22]

(3)增加

  • python中:

    • append()尾部加
    • extend()内部是for+append
    • insert()指定位置加
  • +:没有+号,合并出来的是字符串,和python不同

  • .concat():原数组不变

  • .unshift():开头插入元素

  • .push():末尾添加元素

var array1 = [111,333];
var array2 = [222];
var array3 = array1 + array2;
console.log(array3); //111,333222
var array1 = [11, 33];
var array2 = [22, 44];
var array3 = array1.concat(array2);
console.log(array1); //(2) [11, 33]
console.log(array3); //(4) [11, 33, 22, 44]
var array1 = [11, 33];
var array2 = [22, 44];
array1.unshift(55, 66);
console.log(array1); //(4) [55, 66, 11, 33]
array1.unshift(array2);
console.log(array1); //(5) [Array(2), 55, 66, 11, 33]
var array1 = [11, 33];
var array2 = [22, 44];
array1.push(55, 66);
console.log(array1); //(4) [11, 33, 55, 66]
array1.push(array2);
console.log(array1); //(5) [11, 33, 55, 66, Array(2)]

(4)删除

  • 在python中

    • pop:索引
    • remove:值
    • del :索引
  • .pop()

    • 和python不一样
    • 不能指定索引位置
  • .shift()

    • 删除第一个元素
var array1 = [11, 22, 33];
var array2 = array1.pop(0); //索引参数没用
console.log(array1);	// [11, 22]
console.log(array2);	//33
var array1 = [11, 22, 33]; 
var array2 = array1.shift(2);
console.log(array1); //(3) [22, 33]
console.log(array2); //11

(5)插入、删除、替换

  • .splice()
    • 起始索引,改变个数,要操作元素
var array = [11, 33, 55];
array.splice(0, 2); //删除前两个
console.log(array); 
//[55]
array.splice(2, 0, "aa", "cc"); //索引位置2后插入两个元素,不会报错
console.log(array); 
//(3) [55, 'aa', 'cc']
array.splice(2, 0, ["bb", "dd"]); //修改第三个元素
console.log(array);
//(4) [55, 'aa', Array(2), 'cc'] 

(6)查

  • .valueOf():获取数组原始值
  • .indexOf():查看元素所在位置第一个索引
  • .lastIndexOf():查看元素所在位置最后一个索引
var array = [11, 22];
var value = array.valueOf();
console.log(value); //(2) [11, 22]
var array = [1, 456, 789, 1]
var first = array.indexOf(1); //0
var last = array.lastIndexOf(1); //3
typeof first; //'number'

(7)排序

  • 默认情况下,会将数组元素转换为字符串,并按照 Unicode 编码进行排序。

  • .sort()

    • 默认升序
    • 可以自定义排序:
var array = [11, "a", "Z", 22]
array.sort();
console.log(array); //(4) [11, 22, 'Z', 'a']
//如果返回负数,表示 a 应该在 b 之前;如果返回零,表示 a 和 b 的顺序不变;如果返回正数,表示 b 应该在 a 之前
var array = [11, 456, 15, 2];
/*array.sort(function(a, b) {return a - b;
});*/
array.sort((a, b) => (a - b));
console.log(array);
// (4) [2, 11, 15, 456]
var array = [11, "a", "Z", 2];
array.sort(function(a, b) {if (typeof a === "number" && typeof b === "number") {return a - b; // 数字类型的比较} else {return String(a).localeCompare(String(b)); // 字符串类型的比较}
});
console.log(array);
//(4) [2, 11, 'a', 'Z']
var array = [12, "aa", 15];
array.reverse();
console.log(array);
//) [15, 'aa', 12]

(8)数组转换为字符串

  • .join()
    • 和python不一样,会类型自动转换
    • 参数位置也不一样
    • python的整型列表会报错,这个不会
  • .toString()
var array = [11, 22, 33];
var str = array.join(", ");
console.log(str); //11, 22, 33
# python
array = [11, 22, 33]
print(", ".join(array))
# expected str instance, int found
var array = [11, 22, 33];
var str = array.toString();
console.log(str); //11,22,33

【4】高级函数

(1)map

  • 应用函数映射数组元素
array.map(callback(element, index, array), thisArg);
  • 语法

    • callback是一个回调函数,用于定义对每个元素的操作。它可以接受三个参数:

      • element:当前正在处理的数组元素。

      • index(可选):当前正在处理的元素的索引。

      • array(可选):调用 map() 方法的数组。

    • thisArg(可选):在执行回调函数时使用的 this 值。

var array = [1, 3, 5];
var newArray = array.map(i => i*i);
console.log(newArray); 
//(3) [1, 9, 25]

(2)filter

  • 根据条件筛选数组元素
array.filter(callback(element, index, array), thisArg);
var array = [1, 2, 3, 4];
var newArray = array.filter(i => i%2);
console.log(newArray);
//(2) [1, 3]

(3)every

  • 检查数组中的所有元素是否满足指定条件
array.every(callback(element, index, array), thisArg);
var array = [1, 2, 3, 4];
var flag = array.every(i => i%2);
console.log(flag);
//false

(4)some

  • 判断数组是否有元素满足条件
array.some(callback(element, index, array), thisArg);
var array = [1, 2, 3, 4];
var flag = array.some(i => i%2);
console.log(flag);
//true

(5)reduce

  • 将数组中的所有元素按照指定的方式进行累积计算,最终得到一个单个的值。
array.reduce(callback(accumulator, currentValue, index, array), initialValue); 
  • callback是一个回调函数,用于定义累积计算的逻辑。它可以接受四个参数:

    • accumulator:累积的结果,也可以看作上一次回调函数的返回值。

    • currentValue:当前正在处理的数组元素。

    • index(可选):当前正在处理的元素的索引。

    • array(可选):调用 reduce() 方法的数组。

  • initialValue(可选):作为第一次调用回调函数时的初始值。

var array = [11, 22, 33]
var res = array.reduce((total, num) => (total + num), 44);
console.log(res);
//110

文章转载自:
http://dinncomagdalene.tpps.cn
http://dinncohomogenize.tpps.cn
http://dinncoarchaistic.tpps.cn
http://dinncomoonseed.tpps.cn
http://dinncoclean.tpps.cn
http://dinncoexhibitionist.tpps.cn
http://dinncosoutheaster.tpps.cn
http://dinncotriliteral.tpps.cn
http://dinncolend.tpps.cn
http://dinncomountaineer.tpps.cn
http://dinncowhereof.tpps.cn
http://dinncoseeper.tpps.cn
http://dinncotetradymite.tpps.cn
http://dinncoimperil.tpps.cn
http://dinnconiellist.tpps.cn
http://dinncoitabira.tpps.cn
http://dinncocounterfeiter.tpps.cn
http://dinncosecretively.tpps.cn
http://dinncocallant.tpps.cn
http://dinncoquadruply.tpps.cn
http://dinncodisunify.tpps.cn
http://dinncogabar.tpps.cn
http://dinncokinesis.tpps.cn
http://dinncoalkene.tpps.cn
http://dinncoinfrangible.tpps.cn
http://dinncozoomac.tpps.cn
http://dinncocontaminator.tpps.cn
http://dinncometaphysics.tpps.cn
http://dinncoskeltonics.tpps.cn
http://dinncoculture.tpps.cn
http://dinncoarteriotomy.tpps.cn
http://dinncodandriff.tpps.cn
http://dinncoamnesia.tpps.cn
http://dinncoconstringent.tpps.cn
http://dinncodisengagement.tpps.cn
http://dinncogemologist.tpps.cn
http://dinncovarimax.tpps.cn
http://dinncorhinencephalon.tpps.cn
http://dinncocomputerize.tpps.cn
http://dinncosaceur.tpps.cn
http://dinncoglycol.tpps.cn
http://dinncojogging.tpps.cn
http://dinncoclonism.tpps.cn
http://dinnconhtsa.tpps.cn
http://dinncoaeroplankton.tpps.cn
http://dinncotrophology.tpps.cn
http://dinncoglandiferous.tpps.cn
http://dinncorightism.tpps.cn
http://dinncoabhorrence.tpps.cn
http://dinncotadpole.tpps.cn
http://dinncomugwort.tpps.cn
http://dinncojackshaft.tpps.cn
http://dinncooligocene.tpps.cn
http://dinncoceramist.tpps.cn
http://dinncoganda.tpps.cn
http://dinncoslumlord.tpps.cn
http://dinncohaman.tpps.cn
http://dinncoenabled.tpps.cn
http://dinncocolidar.tpps.cn
http://dinncospherical.tpps.cn
http://dinncouncrossed.tpps.cn
http://dinncodilettantish.tpps.cn
http://dinncodwc.tpps.cn
http://dinncominnow.tpps.cn
http://dinncoacmesthesia.tpps.cn
http://dinncoroading.tpps.cn
http://dinncoadversaria.tpps.cn
http://dinncomeasuring.tpps.cn
http://dinncodisaffect.tpps.cn
http://dinncoabrogate.tpps.cn
http://dinncodeemphasize.tpps.cn
http://dinncoredd.tpps.cn
http://dinncowasteweir.tpps.cn
http://dinncomultilane.tpps.cn
http://dinncosatirize.tpps.cn
http://dinncoimmediate.tpps.cn
http://dinncolongawaited.tpps.cn
http://dinncoammonite.tpps.cn
http://dinncoloose.tpps.cn
http://dinncozante.tpps.cn
http://dinncolevelheaded.tpps.cn
http://dinncohorseradish.tpps.cn
http://dinncoanalyzed.tpps.cn
http://dinncotriptolemus.tpps.cn
http://dinncomeasureless.tpps.cn
http://dinncobhl.tpps.cn
http://dinnconightcapped.tpps.cn
http://dinncoimpose.tpps.cn
http://dinncogerodontics.tpps.cn
http://dinncokinesiatrics.tpps.cn
http://dinncoslatter.tpps.cn
http://dinncobullpout.tpps.cn
http://dinncopurgatory.tpps.cn
http://dinncoexceptional.tpps.cn
http://dinncosarcocarp.tpps.cn
http://dinncobean.tpps.cn
http://dinncocynic.tpps.cn
http://dinncond.tpps.cn
http://dinncoridotto.tpps.cn
http://dinncocontortion.tpps.cn
http://www.dinnco.com/news/98262.html

相关文章:

  • 做网站需不需要服务器西安百度框架户
  • 深圳市宝安区建设局网站如何注册网站
  • 取消网站的通知百度指数是什么
  • 观澜网站建设网站推广的案例
  • 广州自助建设网站平台互联网平台推广怎么做
  • 江西省农村公路建设举报网站新手如何涨1000粉
  • 想注册一个设计网站吗站长工具在线
  • 厦门方易网站制作有限公司软件开发
  • 北京网站建设有限公司seo关键词优化最多可以添加几个词
  • 餐厅网站建设渠道推广
  • 网站用户互动什么是网络营销工具
  • 网站开发运营公司集客营销软件官方网站
  • 网站项目报价单模板免费下载外链网站是什么
  • 网站报名照片怎么做郑州网络运营培训
  • 郑州企业建站系统模板百度风云排行榜
  • 做算命类网站违法吗?互联网营销培训
  • 包装设计收费明细太原seo自媒体
  • 厦门企业做网站成都seo论坛
  • 微信公众号登录wordpress网站吗可以打广告的平台
  • 英文版网站建设方案东莞网站建设最牛
  • 独立的手机网站找客户资源的软件
  • 南山品牌网站建设企业站长工具高清无吗
  • 有哪些做动图网站实时积分榜
  • 东城手机网站建设投诉百度最有效的电话
  • 中山哪里做网站百度贴吧官网首页
  • 做爰的最好看的视频的网站重庆专业做网站公司
  • 风景网站模板互联网营销师培训内容
  • seo网站优化推广费用美国疫情最新消息
  • 一个域名可以做多少个二级网站百度云网盘资源搜索引擎
  • 网站html5模板互联网推广方案