In Javascript, Array.isArray () judges the problem.

has the following data:

[{"children":[{"id":886,"name":"new subcategory1"},{"id":887,"name":"new subcategory2"}],"id":885,"name":"new main category1","shopId":125},{"children":[{"id":889,"name":"new subcategory3"},{"id":890,"name":"new subcategory4"}],"id":888,"name":"new main category2","shopId":125},{"children":[{"id":892,"name":"new subcategory5"},{"id":893,"name":"new subcategory6"}],"id":891,"name":"new main category3","shopId":125},{"children":[{"id":895,"name":"new subcategory7"},{"id":896,"name":"new subcategory8"}],"id":894,"name":"new main category4","shopId":125},{"children":[{"id":898,"name":"new subcategory9"},{"id":899,"name":"new subcategory10"}],"id":897,"name":"new main category5","shopId":125}]

then I use Arrays.isArray () to judge that false, should return true.

Mar.09,2021


Array.isArray([{"children":[{"id":886,"name":"new subcategory1"},{"id":887,"name":"new subcategory2"}],"id":885,"name":"new main category1","shopId":125},{"children":[{"id":889,"name":"new subcategory3"},{"id":890,"name":"new subcategory4"}],"id":888,"name":"new main category2","shopId":125},{"children":[{"id":892,"name":"new subcategory5"},{"id":893,"name":"new subcategory6"}],"id":891,"name":"new main category3","shopId":125},{"children":[{"id":895,"name":"new subcategory7"},{"id":896,"name":"new subcategory8"}],"id":894,"name":"new main category4","shopId":125},{"children":[{"id":898,"name":"new subcategory9"},{"id":899,"name":"new subcategory10"}],"id":897,"name":"new main category5","shopId":125}])

it's true


your result is a string, use typeof to see the type


Array.isArray (2) / / false
Array.isArray ([]) / / true

/ / determine whether an object is an array

function isArray(obj) {
    return Object.prototype.toString.call(obj) == "[object Array]";
}
isArray([])    //true
MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1b39f09-2af18.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1b39f09-2af18.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?