javascript empty array
arr = []; // set array=[]
//function
const empty = arr => arr.length = 0;
//example
var arr= [1,2,3,4,5];
empty(arr) // arr=[]const myArray1 = []
// or...
const myArray2 = new Array()var colors = ["red","blue","green"];
colors = []; //empty the arrayif (array === undefined || array.length == 0) {
// array empty or does not exist
}A = [];
var arr1 = ['a','b','c','d','e','f'];
var arr2 = arr1; // Reference arr1 by another variable
arr1 = [];
console.log(arr2); // Output ['a','b','c','d','e','f']
Also in JavaScript:
- javascript percent to int
- javascript object to query string
- jquery delay to call function
- jsonschema string enum
- node js mongoose text index
- how to get value inside span using javascript
- if keypress javascript
- javascript while
- angular wait all subscriptions
- nodejs express server img src
- feathersjs mysql example
- settimeout arrow function javascript
- loop elements in javascript
- how to code print in javascript
- fillstyle
- if odd js
- loop in object javascript
- aos animation angular
- how to change size of image js
- nested if javascript
- firebase contains query realtime
- get the whole value of a number javascript
- passport middleware check if authenticated
- jquery if class clicked