How and why to avoid global variables in JavaScript?

Published on 11-Jan-2018 16:58:30
Avoid global variables or minimize the usage of global variables in JavaScript. This is because global variables are easily overwritten by other scripts. Global Variables are not bad and not even a security concern, but it shouldn’t overwrite values of another variable.On the usage of more global variables in our ... Read More

How do we handle circular dependency between Python classes?

Rajendra Dharmkar
Published on 22-Jan-2018 14:43:11
We have the following code which shows circular dependency between the python classes.class P():      q = Q().do_something();      def do_something(self):          pass  class Q():      p = P().do_something();      def do_something(self):          passIn case of classes, unlike with functions, ... Read More

How to disable JavaScript in Firefox?

Published on 08-Jan-2018 10:43:28
To disable JavaScript in Firefox, follow the below given steps:Go to the address bar, type “about:config” and press Enter:Now, accept the warning and click I accept the risk.A list of advanced settings will be visible now. Type javascript in the search box to reach the javascript settings:After reaching, you can see ... Read More

How to do case-sensitive string comparison in JavaScript?

Published on 05-Jan-2018 17:29:54
As JavaScript is case sensitive, so case-sensitive comparison are simple string comparisons. This can be done without using any JavaScript method:<!DOCTYPE html> <html>    <body>       <h3>JavaScript Strings</h3>       <p id="test"></p>       <script>          var str1 = "amit";       ... Read More

What is the difference between single-line and multi-line comments in JavaScript?

Published on 05-Jan-2018 16:08:59
Single Line commentThe following is a single line comment in JavaScript. Any text between a // and the end of a line is treated as a comment and is ignored by JavaScript.// This is a comment. It is similar to comments in C++Multi-Line commentThe following is a multi-line comment in ... Read More

What Are Whitespace and Line Breaks in JavaScript?

Published on 05-Jan-2018 14:41:09
JavaScript ignores spaces, tabs, and newlines that appear in JavaScript programs. You can use spaces, tabs, and newlines freely in your program and you are free to format and indent your programs in a neat and consistent way that makes the code easy to read and understand.JavaScript ignores whitespaces. For ... Read More

When is a CDATA section necessary within a script tag?

Published on 05-Jan-2018 11:33:39
To avoid parsing the symbols <> &, it is added in <script>…</script>. It is not needed in HTML. Let us see how CDATA is added in <script> tags:<script>    //<![CDATA[       document.write(">");    //]]> </script>Note: CDATA is now deprecated. Do not use.The CDATA Section interface is used within ... Read More

What is the difference between Bower and npm in JavaScript?

Published on 05-Jan-2018 11:22:10
  npmnpm is generally used for managing Node.js modules and does nested dependency tree. It also works for front-end and used for developer tools like Grunt, CoffeeScript, etc.Without using nested dependencies it is difficult to avoid dependency conflicts. So, using npm has proven to be great.Whatever you add in Node is ... Read More

what is enhanced for loop in Java?

Fendadis John
Published on 18-Jan-2018 16:43:31
As of Java 5, the enhanced for loop was introduced. This is mainly used to traverse a collection of elements including arrays.SyntaxFollowing is the syntax of enhanced for loop −for(declaration : expression) {    // Statements }Declaration − The newly declared block variable is of a type compatible with the ... Read More

How many Python classes should I put in one file?

Rajendra Dharmkar
Published on 22-Jan-2018 12:41:05
Python code is organized in files called "modules" and groups of related modules called “packages".A module is a distinct unit that may have one or more closely-related classes. Modules need to be imported before they are read, used, maintained and extended if needed. So a module is a unit or ... Read More