js数组中indesOf方法的使用
<html>
<head>
<title>数组的操作</title>
<script type="text/javascript"> function B(){
var names=["zhangsan","lisi","wangwu"]; var name=document.getElementById("name").value;
var position = names.indexOf(name);
alert(position);
if (position >=0) {
alert("find"+name+"at position"+position);
}else {
alert("not find"+name);
} } </script>
</head>
<body>
<input type="text" name="name" id="name">
<input type="button" value="dian" onclick="B();"> </body>
</html>
js数组中indesOf方法的使用的更多相关文章
- js 数组中的方法
<!DOCTYPE html><html><head> <title>数组的方法</title> <meta charset=&quo ...
- JavaScript中数组中的方法:push()、pop()、shift()、unshift()、slice()、splice()、reverse()、join()、split()、concat()、indexOf()、forEach()、map()、
1.创建数组的几种方法 //a).通过new来创建数组,new可以省略 var arr=new Array(); var arr=Array(); //b). .通过new来创建数组,并且赋值 v ...
- 统计js数组中奇数元素的个数
如何统计一个JS数组中奇数元素的个数呢? 这是群友提出的一个问题,大部分群友给出的是遍历 然后对2取模,得到最终结果. 这样的写法是最容易想得到的,那么有没有其他思路呢? 这里我提供另外一种思路,我们 ...
- javascript数组中的方法
数组中的方法 今天我们来说一下,对数组进行操作的几种方法: //添加 a=[];//空数组 a[0]="我是第一个"; a[2]="我是第三个"; ...
- js数组中的find(), findIndex(), filter(), forEach(), some(), every(), map(), reduce()方法的详解和应用实例
1. find()与findIndex() find()方法,用于找出第一个符合条件的数组成员.它的参数是一个回调函数,所有数组成员依次执行该回调函数,直到找出第一个返回值为true的成员,然后返回该 ...
- js数组中的reverse()方法
reverse方法是将数组中的元素的顺序进行反转,在原数组上操作,然后返回原数组.由于本人是学习js的新人,对reverse函数进行了几个小实验,以下实验均在Chrome浏览器上运行 实验一:reve ...
- JS数组中every(),filter(),forEach(),map(),some()方法学习笔记!
ES5中定义了五种数组的迭代方法:every(),filter(),forEach(),map(),some(). 每个方法都接受两个参数:要在每一项运行的函数(必选)和运行该函数的作用域的对象-影响 ...
- js数组中容易误用的一些方法
1.every和some 两个方法的参数都是一个函数,函数的有3个参数,依次是当前值value,索引index,数组array every判断数据中的每一项是否满足某个条件,如果满足就返回true,有 ...
- JS数组中的indexOf方法
前言 这两天在家中帮朋友做项目,项目中使用了数组的indexOf 方法,找到了一篇文章,感觉非常不错,顺便整理下以防链接丢失. 相信说到 indexOf 大家并不陌生,判断字符串是否包涵子字符串时特别 ...
随机推荐
- What you should know about .so files
In its early days, the Android OS was pretty much supporting only one CPU architecture: ARMv5.Do you ...
- Bat脚本实现监控进程功能
脚本不间断监控notepad.exe进程是否执行,若停止,则自动重启该进程,程序如下: @echo off set _task = notepad.exe set _svr = c:\windows\ ...
- 题目1029:魔咒词典(map使用以及字符串读取函数总结)
题目链接:http://ac.jobdu.com/problem.php?pid=1029 详解链接:https://github.com/zpfbuaa/JobduInCPlusPlus // // ...
- LeetCode 12 Integer to Roman (整数转罗马数字)
题目链接: https://leetcode.com/problems/integer-to-roman/?tab=Description String M[] = {"", ...
- 根据json对象的值替换json数组里的值
功能: var fruitArry=[{name:'durian'},{name:'peach'},{name:'banana'},{name:'pitaya'},{name:'apple'},{na ...
- 熟悉使用ConfigParser库读写配置文件
Python的配置文件 配置文件 setting.ini文件是一个纯文本 [DataBase1] username = admin passwors = root [DataBase2] hostna ...
- Ruby require, load include 区别
Require, load用于文件, *.rb require一般用于加载库文件,load加在配置文件,ruquire可省略“.rb",它指挥在第一次时候载入,如在字require就被忽略 ...
- 更新jenkins插件,报错 Perhaps you need to run your container with "-Djava.awt.headless=true"?
Configuring the Java environment variables vi ~/.bash_profile 在最后一行加入: export JAVA_OPTS=-Djava.awt.h ...
- Centos 安装 MySQL-python
更新yum yum update yum install mysql-devel yum install gcc yum install python-devel pip install MySQL- ...
- [工具] Citavi – 文献管理软件(笔记记录)
https://www.citavi.com/en/ 如果你有论文写作的需求,特别是对于科研人员.研究生来说,文献管理软件是不可或缺的.目前流行的文献管理软件有老牌的 EndNote,本土化的 Not ...