What is for loop statement in JavaScript?

Nancy Den
Published on 16-Jan-2018 17:30:40
The 'for' loop is the most compact form of looping. It includes the following three important parts −The loop initialization where we initialize our counter to a starting value. The initialization statement is executed before the loop begins.The test statement which will test if a given condition is true or not. If ... Read More

What is Conditional Operator (?:) in JavaScript?

Anvi Jain
Published on 11-Jan-2018 23:43:14
The conditional operator or ternary operator first evaluates an expression for a true or false value and then executes one of the two given statements depending upon the result of the evaluation.Sr.NoOperator and Description1?: (Conditional )If Condition is true? Then value X : Otherwise value YExampleYou can try to run ... Read More

What characters are valid for JavaScript variable names?

Amit Sharma
Published on 16-Jan-2018 17:13:08
To check the valid characters for JavaScript variable names, you should follow the below given naming conventions, which discuss about other rules to name a variable −Name can begin with $ and _ characters, for example, _result.You should not use any of the JavaScript reserved keywords as a variable name. ... Read More

What is the difference between Declaring and Initializing a variable in JavaScript?

Johar Ali
Published on 12-Jan-2018 17:05:14
The following is stated about declaration and initialization of a variable in ECMAScript specification −A var statement declares variables that are scoped to the running execution context’s VariableEnvironment. Var variables are created when their containing Lexical Environment is instantiated and are initialized to undefined when created. [...] A variable defined ... Read More

How we can split Python class into multiple files?

Rajendra Dharmkar
Published on 25-Jan-2018 15:10:51
To split a python program or a class into multiple files, we need to refactor and rewrite the code into two or more classes as per convenience while ensuring that the functionality of the original code is maintained. The answer to this question is as above in a generic way ... Read More

What is the correct way to define global variables in JavaScript?

Ramu Prasad
Published on 02-Jan-2018 10:36:06
A global variable has global scope which means it can be defined anywhere in your JavaScript code.Within the body of a function, a local variable takes precedence over a global variable with the same name. If you declare a local variable or function parameter with the same name as a ... Read More

What are the rules for JavaScript's automatic semicolon insertion (ASI)?

Amit Sharma
Published on 11-Jan-2018 12:15:20
JavaScript’s automatic semicolon insertion (ASI) is to insert missing semicolons. The following statements are affected by automatic semicolon insertion −empty statement var statement expression statement do-while statement continue statement break statement return statement  throw statementThe rules are in the following specification −When, as a Script or Module is parsed from ... Read More

What is the difference between JavaScript and C++?

Sreemaha
Published on 05-Jan-2018 16:11:03
The following are the differences between JavaScript and C++.JavaScript is a lightweight, interpreted programming language. It is designed for creating network-centric applications. It is complementary to and integrated with Java. JavaScript is very easy to implement because it is integrated with HTML. It is open and cross-platform.C++ is a middle-level ... Read More

Do you think declarations within Python class are equivalent to those within __init__ method?

Rajendra Dharmkar
Published on 25-Jan-2018 14:51:31
Declarations anywhere in the class(other than in __init__) and declarations in the __init__method are not the same. The following code shows this to be true.Exampleimport sys class foo():     print 'within class'     def __init__(self):         print 'within init'     def do_smthng(self):     ... Read More

How to draw a rectangle in HTML5 SVG?

Monica Mona
Published on 22-Jan-2018 14:52:44
SVG stands for Scalable Vector Graphics and is a language for describing 2D-graphics and graphical applications in XML and the XML is then rendered by an SVG viewer. Most of the web browsers can display SVG just like they can display PNG, GIF, and JPG.To draw a rectangle in HTML ... Read More
Advertisements