Tag: javascript
All the articles with the tag "javascript".
What is a closure in javascript?
Published: at 03:53 AMWhen a function is enclosed within another function and the enclosed function has access to the variable in the surrounding environment. That is, the variables of the enclosing function, then are called closure.
How to use Array map method in Javascript
Published: at 03:53 AMArray.prototype.map() method iterates over the given array and returns a new value for each item in the array.
Why you should avoid magic numbers in code?
Published: at 03:53 AMMagic numbers are numbers in code that don't have any meaning to them. So it is always a good practice to assign the number to a variable and name the variable corresponding to its value.
How to eliminate multiple If checks?
Published: at 03:53 AMIt is tedious to return a value based on a key when using multiple If checks. If the new value is added we need to add one more If check for that value. The simple solution is we can use the Config object to the pattern to eliminate this problem.
How to find an element in an array in Javascript?
Published: at 03:52 AMIf you know how to find an element from an array in other languages like python or java, you may think of using the same method to find an element in the array. But there is an easy and default way to find an element in an array in Javascript.