You can reduce the quality of photos to speed up the loading of your site
If you own a website or work on a customer website, then you need to know the importance of SEO. Without proper SEO strategies, you can not get high rankings in Google.
JavaScript is a complex language. If you are a JavaScript developer at any level, it is important to understand the basics. This article addresses 12 concepts that are important for any JS developer to understand, but by no means cover the full extent of what a JS developer needs to know.
Success in a media channel such as organic search depends on the content. In particular, the production of useful content has the ability to rank. In its recent algorithm updates, Google has focused heavily on promoting great content and natural links, and penalizing poor content with unspecified links.
Websites are created using different frameworks and programming languages. The .NET framework is one of the many options you can choose from.
1. Assign a variable with a value compared to a reference
Understanding how to assign variables in JavaScript is essential for writing bug-free JavaScript code. If you do not understand this, you can easily write code that inadvertently changes the values.
JavaScript always assigns variables by value. But this part is very important: when the assigned value is one of the five main types of JavaScript (ie Boolean, null, undefined, String and Number) the actual value is assigned. However, when the assigned value of an array is a function, or object, a reference is assigned to the object in memory.
Example; In the following code, var2 is equal to var1. Since var1 is the main type (String), var2 is set to the value of the strings var1 and can be thought of as quite different from var1 at this point. Accordingly, var2 redistribution has no effect on var1
You may see how it can cause problems if you expect it to behave like assigning primary variables! This can be bad, especially when you create a function that inadvertently changes an object.
2. Closures
Closures are an important JavaScript template for private access to a variable. In this example, createGreeter returns an anonymous function that has access to greeting, "Hello". For all future uses, sayHello will have access to this greeting!
In a more realistic scenario, consider an initial apiConnect function (apiKey) that returns some of the methods that use the API key. In this case, apiKey needs to be prepared only once and does not need to be done again.
3. Destructuring
This is a common way to extract properties from objects.
If you want to extract properties by another name, you can specify them using the following format.
In the following example, this method is used to pass the person object to the introduce function. In other words, this method can be used directly to send the extracted parameters to a function. If you are familiar with React, you have probably seen it before!
4. Spread syntax
The spread operator is a relatively simple concept in JavaScript. In the following example, Math.max cannot be applied to the arr array, because it cannot array as an argument; this method takes unique elements as arrays. The spread bar (...) is used to capture unique elements of an array.
5. Syntax Rest
Let's talk about JavaScript rest syntax. You can use it to put any number of arguments passed to the function in an array.
6. Array methods
JavaScript array methods can often provide incredible and beautiful ways to do the data conversion you need.
Here we cover one of the different array methods, which is organized with similar methods that are sometimes combined.
1. map, filter, reduce
There is some confusion about the methods of the map, filter, and reduce JavaScript array. There are handy methods for converting an array or returning a value together.
map: Returns an array in which each element is converted to an item specified by the function.
filter: Returns an array of elements that returns the true function.
Reduce: Summarizes the values as specified in the function.
7. Generators
Do not be afraid of *. The generator function specifies what the yield value is the next time the next () is called. You can have a limited number of yields after next () returns the undefined value, or returns an unlimited amount of values using a loop.
And use the generator for unlimited values:
8. Identification operator (===) compared to equality operator (==)
Be sure to know the difference between the identification operator (===) and the parity operator (==) in JavaScript. The == operator performs a type conversion before comparing values, while the === operator does no type conversion before comparing.
9. Object comparison
A mistake most newcomers make is direct comparison of objects. Variables refer to references to objects in memory, not to the objects themselves. One way to compare them is to convert objects to JSON strings. This has one drawback: Object property ordering is not guaranteed. A safer way to compare objects is to use a library that specializes in deep comparison of objects, such as isEqual.
The following objects appear to be equal but point to different references.
Instead, the following code is evaluated correctly because one object is equal to another object and therefore refers to the same reference (there is only one object in memory).
Be sure to read the value comparison with reference section above to fully understand the setting of a variable equal to another variable that points to an object in memory.
10. Callback functions
Many people are afraid of JavaScript callback functions! But they are simple. Let's take an example. The console.log function is sent to myFunc as a callback. Runs when setTimeout is complete. That's all there is to it!
Once you understand JavaScript callbacks, you will soon find yourself in nested callbacks. This is where Promises comes in handy. Put your async logic in a Promise and resolve success, rejection or failure. Use "then" to manage success and catch to manage failure.
12. Async Await
When you get to JavaScript promises, you may want to ask for async await. In the following example, we create an async function and await the greeter promise inside it.
Conclusion
If you do not know any of these 12 concepts, you have probably grown at least a little bit of JavaScript knowledge and gained insight into each one. And if you know all of them, I hope this is an opportunity to practice and grow your knowledge. Good luck!
User:sinahabibi
1/25/2021
Visit:94
Java Script