admin管理员组文章数量:1416642
I want to do that in javascript:
for (int i = 0; i <= pieces; i++)
{
List<product> piecesProuducts = productList.Skip(i * 2).Take(2).ToList();
}
I have a json array. I want to get two records block from this json array as above linq code in javascript. Is that possible and how?
I want to do that in javascript:
for (int i = 0; i <= pieces; i++)
{
List<product> piecesProuducts = productList.Skip(i * 2).Take(2).ToList();
}
I have a json array. I want to get two records block from this json array as above linq code in javascript. Is that possible and how?
Share Improve this question asked May 18, 2013 at 9:44 cagincagin 5,93016 gold badges78 silver badges133 bronze badges 1- What does the JSON look like and what should the end result look like? – Ayman Safadi Commented May 18, 2013 at 10:06
1 Answer
Reset to default 5A JSON array is just a JavaScript array, so you can use push and slice.
Here's an example:
var productList = [1,2,3,4,5,6,7,8,9,0]
var piecesProuducts = []
for (var i = 0; i <= 4; i++)
{
piecesProuducts.push(productList.slice(i*2, i*2+2));
}
console.log(piecesProuducts)
本文标签: jqueryHow to do skip and take functions in javascript for Json arrayStack Overflow
版权声明:本文标题:jquery - How to do skip and take functions in javascript for Json array - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1745255719a2650088.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论