javascript - 如何在没有for循环的情况下在JavaScript中显示数组?

标签 javascript arrays parse-platform

我正在尝试查询我在 Parse.com 上使用的信息。 我有一组信息,我想使用 containsIn 方法来查询这些信息。

以下是 Parse 中的示例,说明如何使用包含在方法中:

// Finds scores from any of Jonathan, Dario, or Shawn
query.containedIn("playerName", ["Jonathan Walsh", "Dario Wunsch", "Shawn Simon"]);

这是我尝试的方法:

var holdingTheDaysInCurrentMonth = []; //declare array

//for loop to put info inside of it
for(var i = startDateDay; i <=endDateDay; i++) {
    var dayInMonth = i.toString();
    holdingTheDaysInCurrentMonth.push(dayInMonth);  
}

//... code to query Parse

//how I am calling my method
alert(holdingTheDaysInCurrentMonth.toString());
query.containedIn("dayString", [holdingTheDaysInCurrentMonth.toString()]);

在我的警报中,当我单击该月的 1 号和 6 号时,我会收到 1、2、3、4、5、6 的响应(这是预期的)。我没有从查询中检索到任何行,因此查询肯定是错误的。如何更改格式才能正确使用?我做错了什么?

最佳答案

您需要执行以下操作:

query.containedIn("dayString", holdingTheDaysInCurrentMonth);

第二个参数可以是实际的数组,因此不需要将其转换为字符串。

关于javascript - 如何在没有for循环的情况下在JavaScript中显示数组?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25902263/

相关文章:

java - byte[] 到 String 返回不同的 String

c - 将文件中的数据存储到结构数组中

javascript - array.split ("stop here") array to array of arrays in javascript 数组

javascript - 通过字符串调用 jQuery 定义的函数

javascript - JQuery——有没有办法解决这个问题?

javascript - 将消息从 contentScript 发送到 InjectedScript

java - 如何在 JSF 中忽略导入的外部 javascript

java - 无法解析 com.parse.ParseQueryAdapter

ios - 使用 PFSignUpViewControllerDelegate 注册后无法执行转场

javascript - 如何通过点击收到的链接来实现电子邮件验证?