获取数组中的第一个元素 [英] Get first element in array

查看:160
本文介绍了获取数组中的第一个元素的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何从数组中获取第一个元素:

How do you get the first element from an array:

var ary = ['first', 'second', 'third', 'fourth', 'fifth'];

我试过这个:

alert($(ary).first());

但它会返回 [object Object]

所以我需要从数组中获取第一个元素,该元素应该是元素 first

So I need to get the first element from the array which should be the element first.

推荐答案

像这样

alert(ary[0])

这篇关于获取数组中的第一个元素的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆