如何获得数组的第一个元素? [英] How to get the first element of an array?

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

问题描述

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

How do you get the first element from an array like this:

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

我尝试过:

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

但是它将返回[object Object].因此,我需要从数组中获取第一个元素,该元素应为元素'first'.

But it would return [object Object]. So I need to get the first element from the array which should be the element 'first'.

推荐答案

像这样

alert(ary[0])

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

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