Top 5 Javascript Topics You Should Know
Here are the top 5 topics that are very important for you to learn about Javascript.
If you are working or learning Javascript then here are the tips to know more depth about Javascript.
- Javascript Array: There are many array methods in javascript. Here are some methods,
- toString(): this method converts an array to a string. For example,
- push(): push method used to add new element to an array at the end of the list. It will be added at the last position to the new element. For example:
- pop(): pop array method is used to remove the last element from an array. For example,
- shift(): shift array method is used to remove the first element from an array. For example,
- unshift(): it is used to add a new element at the first position of an array
- splice(): splice array method is used to add new item to an array. It takes two parameters. First parameter define in which position will be added the new element. Second parameter used to remove the items from an array.
- slice(): it is used to slice elements to a new array
- concat(): concat method is used to create a new to by merging from an existing array.
2) Var let const : before es6 we used var to declare a variable. In es6 we can declare a variable using the let and const keyword. We can declare a variable using let and also can re-assign the value. But when we declare a variable using const keyword then we can’t re-assign the value. It will throw an error if we try to re-assign a value to const.
3) Default parameter: we can now set the function default parameter. It is a new feature to es6. It is very useful. When we declare a function a call without arguments then it will return noting. We can now set the default parameter to a function and set up the default parameter if we call the function without any arguments then it will work and respond from the default parameter.
4) Template String: template string is a revolutionary update in es6. Template string is used with the ( `` ) backtich key. We can now easily write string and also write variables in this template string. We can also do calculation using this template string. For example: console.log(`we can now do addition ${5+5}`) it will return we can now do addition 10. It is very useful for the developers.
5) String Methods: there are many string methods. Some of them are,
- charAt: we can get the character position using chatAt to string. It will start counting with 0. For example,
- Concat: this is used to concat strings.
- Includes: includes used to check is there the character is available or not. It will return boolean true or false. For example,
- slice(): slice is used to slice the specific element or character from the string. It takes two parameter. First parameter is the starting index and second parameter is the ending index. The index starts from 0. For example,
- toUppercase() and toLowerCase(): these are used to change the change the transform of text. For example,
- indexOf(): we can know the index of a specific character by using indexOf. For example,