Get the App
SLTechnology News&Howtos  ›  Development  › 

How JavaScript adjusts / empties arrays using length

Shulou Source: shulou.com Published: 2022-06-01 05:13:14 10月31日 Update

Editor to share with you how JavaScript uses length to adjust / empty arrays, I believe most people do not know much about it, so share this article for your reference, I hope you can learn a lot after reading this article, let's go to know it!

Adjust / empty the array using length

We basically covered the length of the array.

If we want to resize the array:

Var entries = [1,2,3,4,5,6,7]; console.log (entries.length); / / 7 entries.length = 4; console.log (entries.length); / / 4 console.log (entries); / / [1,2,3,4]

If we want to empty the array:

Var entries = [1,2,3,4,5,6,7]; console.log (entries.length); / / 7 entries.length = 0; console.log (entries.length); / / 0 console.log (entries) / / [] what is JavaScript? JavaScript is a literal scripting language whose interpreter is called JavaScript engine and is part of the browser. JavaScript is a scripting language widely used on the client side. It was first used on HTML pages to add dynamic functions to HTML pages.

These are all the contents of the article "how JavaScript adjusts / empties arrays using length". Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!

Tags: Array adjustment article content web page script language not much function dynamic size most customer engine is in more browser literal translation knowledge end Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Microsoft Xiaomi Docker MariaDB Shulou Technology