jQuery toggleClass example

Toggle class name on click in jQuery

by SnehalKadwe

CSS

body {
  background: #20262E;
  padding: 20px;
  font-family: Helvetica;
}

JavaScript

const clothing = ['shoes', 'shirts', 'socks', 'sweaters'];
const colors = ['red', 'pink', 'orange'];

/* get the element from the given index value */
const index = 3;
console.log(`element on ${index} indexed position is =  ${clothing.at(index)}`);

/* find length of an array */
console.log(clothing.length);
// expected output: 4

/* ex to concat 2 arrays */
console.log(clothing.concat(colors));

/* ex of array.fill() */
const arr = [1,2,3,4,5,6,7];
/* 1 is the start range and 3 is the end range while 7 is a static value which will be replace and return a modified array*/
console.log(arr.fill(7, 1,3));
console.log(arr.fill(8,3)); // start replacing value 8 from index position 3
console.log(arr.fill(9)); // static value 9