JavaScript Errors – Solutions – Blogging for Beginner – WhyBlogging.comhttps://whyblogging.com
blogging ehowThu, 31 Jan 2019 16:53:09 +0000enhourly1https://wordpress.org/?v=5.0.4How I get query string values in JavaScript?https://whyblogging.com/get-query-string-values-javascript/
https://whyblogging.com/get-query-string-values-javascript/#respondSun, 02 Oct 2016 10:46:15 +0000http://whyblogging.com/?p=1720Today i am going to show you, how you can get string values by using JavaScript ?. Yes you can do it by using pure JavaScript, you do not need any JavaScript Plugin or library for this task. JavaScript have some build-in method for getting query string values. Here is the code of JavaScript by ...

]]>Today i am going to show you, how you can get string values by using JavaScript ?. Yes you can do it by using pure JavaScript, you do not need any JavaScript Plugin or library for this task. JavaScript have some build-in method for getting query string values. Here is the code of JavaScript by following this you can easily handle query values in JavaScript.

]]>https://whyblogging.com/get-query-string-values-javascript/feed/0How to “Checked” a checkbox by using jQuery?https://whyblogging.com/checked-checkbox-using-jquery/
https://whyblogging.com/checked-checkbox-using-jquery/#respondSat, 01 Oct 2016 10:36:39 +0000http://whyblogging.com/?p=1718The problem is many beginner programmer have a question and i saw same question on various forum that how to checked a checkbox by using jQuery ? either single checkbox or multiple, so here i am going to solved the problem. If you are using jQuery version 1.6 and onward then .prop() method is the ...

]]>The problem is many beginner programmer have a question and i saw same question on various forum that how to checked a checkbox by using jQuery ? either single checkbox or multiple, so here i am going to solved the problem.

If you are using jQuery version 1.6 and onward then .prop() method is the best option for you, more about .prop method.

]]>https://whyblogging.com/checked-checkbox-using-jquery/feed/0How to Check if Checkbox is Checked or not in jQueryhttps://whyblogging.com/check-checkbox-checked-not-jquery/
https://whyblogging.com/check-checkbox-checked-not-jquery/#commentsWed, 28 Sep 2016 11:48:42 +0000http://whyblogging.com/?p=1713This tutorial show you how to check, Is checkbox either checked or not in jQuery?. To check checkbox is checked or not is very simple task, after searching on the internet i am going to discuss the easiest and authentic solution of it. Here i describe three solutions, its depend on you which you follow ...

]]>This tutorial show you how to check, Is checkbox either checked or not in jQuery?. To check checkbox is checked or not is very simple task, after searching on the internet i am going to discuss the easiest and authentic solution of it. Here i describe three solutions, its depend on you which you follow or your which jQuery version you are using.

// Selecting the checkbox & filtering by :checked selector $(‘#checkbox:checked’).length // Integer >0 $(‘#checkbox:checked’).size() // .size() can also be used instead of .length

Which is the recommended method for check the checkbox is checked or Not in JQuery?

The answer is .prop method is recommended for check the checkbox in jQuery. .prop methodavailable 1.6 and latest version of jQuery. A .prop method is used to sets and return properties or values of the selected elements. In the previous version of jQuery .attr() method was used instead.

]]>https://whyblogging.com/check-checkbox-checked-not-jquery/feed/1Which is the best way to use value for loading JavaScript link “#” or javascript:void(0)”?https://whyblogging.com/best-way-use-value-loading-javascript-link-javascriptvoid0/
https://whyblogging.com/best-way-use-value-loading-javascript-link-javascriptvoid0/#respondWed, 28 Sep 2016 10:55:21 +0000http://whyblogging.com/?p=1711Going to discuss which href value is best for load JavaScript function “#” or javascript:void(0)”?. Here there are two methods available which you can use when user click on the link the JavaScript function execute. 1. Load JavaScript function by using “#” in href value. <a href=”#” onclick=”yourJsFnc();”>Execute JavaScript Code</a> 2. Load JavaScript function by ...

]]>Going to discuss which href value is best for load JavaScript function “#” or javascript:void(0)”?. Here there are two methods available which you can use when user click on the link the JavaScript function execute.

1. Load JavaScript function by using “#” in href value.

<a href=”#” onclick=”yourJsFnc();”>Execute JavaScript Code</a>

2. Load JavaScript function by using “javascript:void(0)” in href value.

1. Load function by using href=”#” and the function return some value and do something then function return task will not execute.

function doSomething() { //Some code return some-value; // not be executed}
2. Another reason is that if calling function throw any exception or error the return statement is not executed. So must solved any error you may know occur during the execution of calling function.

So avoid all problems discuss in the post you should use javascript:void(0) in href value to load or execute JavaScript function.

]]>https://whyblogging.com/best-way-use-value-loading-javascript-link-javascriptvoid0/feed/0How you can include a JavaScript file to another JavaScripthttps://whyblogging.com/can-include-javascript-file-another-javascript/
https://whyblogging.com/can-include-javascript-file-another-javascript/#respondTue, 27 Sep 2016 17:08:21 +0000http://whyblogging.com/?p=1709Many programmers have queries that how they can include a JavaScript file to another JavaScript, Is there any way to achieve ? The answers is JavaScript does not support methods include, import, required like other programming languages supports. But there are some other ways available in JavaScript to import/include JavaScript file in another JavaScript file. ...

]]>Many programmers have queries that how they can include a JavaScript file to another JavaScript, Is there any way to achieve ? The answers is JavaScript does not support methods include, import, required like other programming languages supports. But there are some other ways available in JavaScript to import/include JavaScript file in another JavaScript file.

1. Loading JavaScript file using Ajax.

It is an easy way to add JavaScript file in another JavaScript file using Ajax call and then call eval method. eval() function evaluate or execute JavaScript code or expression. It is little risky if you are using eval() function in your code, it opens the door for bugs and hacks.

So here i discuss several ways load JavaScript file, you can adopt any one of these method and if you have another solution of the problem then comment below, I should consider and it also help for the readers.

]]>https://whyblogging.com/can-include-javascript-file-another-javascript/feed/0How to Removed a Element from an Array in JavaScript ?https://whyblogging.com/removed-element-array-javascript/
https://whyblogging.com/removed-element-array-javascript/#respondTue, 27 Sep 2016 03:17:32 +0000http://whyblogging.com/?p=1704Today i am going to discuss how to removed a particular element from the Array in JavaScript. For doing this you need to find the index of specific element which you want to remove from the array, after finding the index you can easily delete that element from the array. JavaScript provides two predefined function ...

]]>Today i am going to discuss how to removed a particular element from the Array in JavaScript. For doing this you need to find the index of specific element which you want to remove from the array, after finding the index you can easily delete that element from the array. JavaScript provides two predefined function splice & indexof by using its you can perform the task.

Splice method is used to adds/removes items from an array and return array containing removed items. This function change the original array. here are cool examples JavaScript method splice.

Example 1 : First find the index of element you need to remove.

var array = [6, 9, 4,3];var indx = array.indexOf(4);

array.indexof method return the index of element 4 then use splice method to removed the particular element from the array.

array.splice(index, 1);

it will removed one item to given index number and the Output is 6 9 3.

Splice JavaScript method supports almost all browsers (Mozilla Firefox, Chome, Internet Explorer etc ). Splice method need 3 parameters first two parameters are required and last one parameter are optional.

First parameter is an Index of element where you want to adds or removes items.Second parameter is used to tell how many number of items to be removed.Last parameter is optional: Number of new item(s) to be added in an array.

]]>https://whyblogging.com/removed-element-array-javascript/feed/0Where we Use === in JavaScript – What is difference between == operator and === operator in JavaScripthttps://whyblogging.com/what-is-difference-between-operator-and-operator-in-javascript/
https://whyblogging.com/what-is-difference-between-operator-and-operator-in-javascript/#respondMon, 26 Sep 2016 17:58:01 +0000http://whyblogging.com/?p=1702Here is another interested JavaScript tutorial for programmers and beginners, I describe where you can use === comparison operator and == comparison operator. And what is difference between these operators. The comparison === operator compare the two values, if it is equal or not as well its data type and it return True if vale ...

]]>Here is another interested JavaScript tutorial for programmers and beginners, I describe where you can use === comparison operator and == comparison operator. And what is difference between these operators.

The comparison === operator compare the two values, if it is equal or not as well its data type and it return True if vale is equal and same data type while == operator return True whether the data type of operand are same or not.

Here are some more examples:

1. For operands data type is number then :

var x = 1;
var y = 1;

x === y returns true if x and y have the same value and are of the same data type.
x ==y returns also true.

2. If both operands data type is string.

var x = “abc”;var y = “abc”;

x === y returns true if x and y are both strings and contain the exact same number of characters.x == y returns also true.

3. For operands data type is different but have same value (==):

var x = 1;var y = “1”;

x === y returns False if x and y have same value but different data type.x == y returns True if x and y have same value but different data type. Data type is not matter in == comparison operator.

Now you understand the use of === operator and == operator in JavaScript. Once again i tell you that wherever you want to compare value along with it data type use === comparison operator, whereas use == operator if you would like to check only value of variables.

]]>https://whyblogging.com/what-is-difference-between-operator-and-operator-in-javascript/feed/0Differentiate declaration syntax: function fn() {} vs var fn = function() {} in JavaScripthttps://whyblogging.com/differentiate-declaration-syntax-function-fn-vs-var-fn-function-javascript/
https://whyblogging.com/differentiate-declaration-syntax-function-fn-vs-var-fn-function-javascript/#respondMon, 26 Sep 2016 17:00:07 +0000http://whyblogging.com/?p=1698In the post i discuss why programmers use of function fn() {} and var fn = function() {} in JavaScript? What is difference between these two functions and pros & cons of using the functions. The problem you face when you reuse or optimize the code of another developer, you get confuse why he used ...

]]>In the post i discuss why programmers use of function fn() {} and var fn = function() {} in JavaScript? What is difference between these two functions and pros & cons of using the functions. The problem you face when you reuse or optimize the code of another developer, you get confuse why he used function fn() {} in one place and var fn = function() {} in another line of code, after reading the post you get better idea of these two functions.

var fn = function() {} is a function expression while function fn() {} is a function declaration and it is define when script is executed.

Example of function expression.

// TypeError: undefined is not a function functionexp();

var functionexp = function() { console.log(“HelloWorld!”); };

Example of function declaration.

// Outputs: “Hello!” functiondec();

function functiondec() { console.log(“HelloWorld!”); }

Another difference of function expression and function declaration, are you can not add function declaration in conditional statements (if, if else, switch etc) of JavaScript. if you want to use function in conditional statement use “use strict” in the function or start of the JavaScript file. More about strict mode.

]]>https://whyblogging.com/differentiate-declaration-syntax-function-fn-vs-var-fn-function-javascript/feed/0How to Check a Element is Hidden or Not in jQueryhttps://whyblogging.com/check-element-hidden-not-jquery/
https://whyblogging.com/check-element-hidden-not-jquery/#respondMon, 26 Sep 2016 11:10:49 +0000http://whyblogging.com/?p=1694Various jQuery programmers search on the Google that it is possible to check if an element is hidden in jQuery/JavaScript. There are two predefined functions are available in jQuery by using it you can easily check the element is hidden or not in jQuery. Here is a simple code to do that. Use hidden selector ...

]]>Various jQuery programmers search on the Google that it is possible to check if an element is hidden in jQuery/JavaScript. There are two predefined functions are available in jQuery by using it you can easily check the element is hidden or not in jQuery.

]]>https://whyblogging.com/check-element-hidden-not-jquery/feed/0Why people “use strict” in JavaScript Code and What is main Reason behind it?https://whyblogging.com/people-use-strict-javascript-code-main-reason-behind/
https://whyblogging.com/people-use-strict-javascript-code-main-reason-behind/#respondSun, 25 Sep 2016 17:54:25 +0000http://whyblogging.com/?p=1689Many programmers and developers have problem whenever they run a JavaScript code, normally the error is: Problem at line 22 character 1: Missing “use strict” statement. This is because some programmers do not use “use strict” in the code which causes the error. you can also add “use strict” if you face the same problem ...

]]>Many programmers and developers have problem whenever they run a JavaScript code, normally the error is:

Problem at line 22 character 1: Missing “use strict” statement.

This is because some programmers do not use “use strict” in the code which causes the error. you can also add “use strict” if you face the same problem while running the code.

Why People add “use strict” in JavaScript?

JavaScript introduced a new feature in ECMAScript 5, which allow programmers to add a function or a program in a strict operating context. by doing this your function or a program prevent from more exceptions. You can simply enabled the strict mode by adding ” use strict ” at the top of the JavaScript file or in the function.

I strongly recommend JavaScript programmers to use strict mode ” use strict ” in the code, now almost all browsers supporting it because it help us to prevents from the errors which we do not know where it is in the code, so it is very helpful for programmers for write code in peace. Hope this would be help full for you.

Note: It is noted that strict mode available in Monzilla Firefox is different from ECMAScript 5’s strict mode.