简体   繁体   中英

JS .splice() on object array

Why do i always get "... .splice() is not a function" when using it on arrays with objects??

Does indeed work with numbers, but I need it with objects.

https://jsfiddle.net/a1nq1p73/1/

arrayWithObjects.splice(0,1); // "TypeError: ... not a function"

I am trying to rearrange sections ( position:absolute ) by their left property.

getElementsByTagName does not return an array, the method returns a live HTMLCollection of elements. You would need to convert it to an array.

var divs = document.getElementsByTagName("div");
var nowItIsAnArray = [].slice.call( divs);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM