Posts
Spread and Rest Operator
- Get link
- X
- Other Apps
We use these operators many times. It's only one operator (...). Spread It is used to split up array elements OR object properties. As object and array in JS is copied by reference by default, so we use it to copy by value. / / [...oldArray] => will return all the values of old array in the form of array, but only value is assigned, not reference // [...oldArray, element1, element2] => will return all the elements of old array also element1 and element2 in the form of array const array = [ 2 , 5 , 6 , 2 , 1 , 345 ] // // Copy...
JavaScript Classes
- Get link
- X
- Other Apps
Classes are present in many programming languages. For using classes in Js, we use the class keyword. A class contains properties and methods. It supports constructor, to create some properties, inheritance etc. We use this keyword to use interact with methods and properties. Eg: // Human class class Human { constructor () { this . gender = "Male" -> Property } printGender = () => { -> Method console . log ( this . gender ); } } const newHuman = new ...