# :blue_book: Array.prototype.length The **`length`** property აბრუნებს არაიში არსებული ელემენტების რაოდენობას. --- --- # :pencil: Syntax/სინტაქსი --- ``` const clothing = ['shoes', 'shirts', 'socks', 'sweaters']; console.log(clothing.length); ``` --- # :bulb: Description/აღწერა --- :::info საინტერესოა ის რომ array -ს შეგიძლია მიანიჭო length, თუმცა ეს რიცხვი აუცილებლად უნდა იყოს მთელი დადებითი რიცხვი და ნაკლები 2 ის 32-ე კვადრატისა. ::: --- # :key: Example/მაგალითი --- ``` const listA = [1,2,3]; const listB = new Array(6); console.log(listA.length); // 3 console.log(listB.length); // 6 listB.length = 4294967296; //2 to the 32nd power = 4294967296 // RangeError: Invalid array length const listC = new Array(-100) //negative sign // RangeError: Invalid array length ``` ``` const arr = [1, 2]; console.log(arr); // [ 1, 2 ] arr.length = 5; // set array length to 5 while currently 2. console.log(arr); // [ 1, 2, <3 empty items> ] ``` ``` const numbers = []; numbers.length = 3; console.log(numbers); // [empty x 3] ``` --- ### :bookmark_tabs: resources / წყარო --- https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/length ---