javascript

child theme

Basic array operations in Javascript

How to add elements at the start of an array in javascript? let list1 = [‘b’, ‘c’]; //using spread operator console.log([‘a’, …list1]); //Or using unshift method list1.unshift(‘a’); console.log(list1); How to add elements at the end of an array in javascript? let list2 = [‘a’, ‘b’]; //using spread operator console.log([…list2, ‘c’]); //or push method list2.push(‘c’); console.log(list2);

Basic array operations in Javascript Read More »

What is async attribute in script tag in javascript?

What is async attribute in script tag in javascript? <script src=”test.js” async></script> If async attribute is present in script tag then script is executed asynchronously. async attribute is a Boolean attribute. What is the difference between async and defer? If async is present the file gets downloaded asynchronously and then executed as soon as it’s

What is async attribute in script tag in javascript? Read More »