+ 2

size and length in javascript

what is the difference between array.size() and array.length() , and show me the example thanks

20th Aug 2018, 2:49 PM
Mohammed Yaseen
Mohammed Yaseen - avatar
2 Answers
+ 2
I think that you think about about: array.size() and array.length array.length is property that returns number of elements in array. ---------- Example: ---------- var array =["one","two","three"]; var array2 = [1,2,3]; var array3 = [[1,1],[2,2],[3,3]]; console.log(array.length); //3 console.log(array2.length); //3 console.log(array3.length); //3 ---------- array.size() is a function for example in jquery library, when you dont have this library on you project output returns ---------- Example ---------- var array =["one","two","three"]; var array2 = [1,2,3]; var array3 = [[1,1],[2,2],[3,3]]; console.log(array.size()); console.log(array2.size()); console.log(array3.size()); // TypeError: array.size() in not a function ----------
20th Aug 2018, 3:41 PM
Dawid
Dawid - avatar
0
Dawid thank you very much
20th Aug 2018, 4:42 PM
Mohammed Yaseen
Mohammed Yaseen - avatar