}

Javascript Index Page 1

How to update package.json libraries to the latest version>

package.json contains information about your project, to update libraries automatically you can use

Javascript Index Page 1

How to Trim String in JavaScript ?

With javascript if you need to remove the spaces on left and right you can use trim. If you need to trim only the left side of the string use replace with a regex, ex: str.replace(/^s+/,'');. Check this article for more details

Javascript Index Page 1

How to Trim String in JavaScript ?

With javascript if you need to remove the spaces on left and right you can use trim. If you need to trim only the left side of the string use replace with a regex, ex: str.replace(/^s+/,'');. Check this article for more details

Javascript Index Page 1

Javascript: How to remove a specific element from an array?

In this small tutorial we will give example on how to remove a specific element from an array with javascript. Code example: var index = array.indexOf(5); if (index > -1) { array.splice(index, 1); }

Javascript Index Page 1

How to get selected value of dropdown in javascript (with jQuery example)

We will explain hot to retrieve the selected element using javascript. e.options[e.selectedIndex].value will return the value of the selected element where e is the variable obtained with document.getElementById("selector"). Check here a full jQuery example also. Read our tutorial for more details.

Javascript Index Page 1

Javascript http request: No 'Access-Control-Allow-Origin' header is present on the requested resource error

When you try to fetch data from a different domain using javascript you will get the error: No 'Access-Control-Allow-Origin' header is present on the requested resource. This is a security feature of web browsers. The proper solution is to use CORS, check here for full solution. Alterntive you can code a custom proxy or use JSONP.

Javascript Index Page 1

JavaScript: How to know if and Object is empty?

In general there is now way to check is a javascript object is empty. We create a new function to verify if the object is empy. As an optional step we add it to the object prototype.

Javascript Index Page 1

JavaScript: Learn key value iteration

Learn key value iteration with some helpful examples. We also cover some examples using jQuery.

Javascript Index Page 1

Javascript: Why you should use for() to iterate

If in your code you are using Array.forEach, check this blog post about the performance of javascript using for(). Learn how to improve the performance of the forEach in javascript.

Javascript Index Page 1

How to Change a DOM element's class with JavaScript

If you want to change element class using javascript you can try: document.getElementById("ElementId").classList.add('NewClass') to add a new class. Alternative methods are remove and contains. Check here for more examples and alternatives using jQuery or coe for older browsers.