Skip to main content

JAVASCRIPT BASICS




JavaScript has programming capabilities similar to the most programming languages such as variables, data types, constants, programming constructs, user defined functions etc..
Characteristics of JavaScript
1. JavaScript is Case Sensitive: Unlike HTML, JavaScript is case sensitive. You need to take care when you write javaScript statements, create or call variables, objects and functions.
2. JavaScript Statements: JavaScript is a sequence of statements that are to be executed by the browser. It is a command to the browser which tells browser what to needs to do. The following JavaScript statement tell the browser to write "Hello" on the web page:

document.write("Hello");

3. You need to add a semicolon at the end of each executable statement. According to the JavaScript standard semicolon is optional and the browser is supposed to interpret the end of the line as the end of the statement. Using semicolons makes it possible to write multiple statements on one line. Also it is a good programming practice.

4. JavaScript Code: JavaScript code (or just JavaScript) is a sequence of JavaScript statements. Each statement is executed by the browser in the sequence they are written. Following code will write a header and a paragraph on the web page:


5. JavaScript Blocks: You can group JavaScript statements in blocks. Such blocks start with a left curly bracket {, and ends with a right curly bracket }. The purpose of a block is to make the sequence of statements execute together. Following example will write a header and paragraphs to a web page:




JavaScript variables
Variables are "containers" for storing information. A variable can have a short name, like x, or a more descriptive name, like carname. Rules for JavaScript variable names:
• Variable names are case sensitive (y and Y are two different variables)
• Variable names must begin with a letter or the underscore character
Note: Because JavaScript is case-sensitive, variable names are case-sensitive.

A variable's value can change during the execution of a script. You can refer to a variable by its name to display or change its value.
Creating Variables in JavaScript
Creating variables in JavaScript is done using var statement [It is most often referred to as declaration of variables].


E.g. Declaration of Variables

var y;
var name;

In the above examples two variables y and name have been declared. Note that these variables are empty as no value has been assigned to them. You can assign values to them as follows:

var y=4;
var name="Kanchi";

In this example y has been assigned value 4 and name has assigned string “Kanchi”. After the execution of the statements above the variable y will hold the value 4, and name will hold the value Kanchi.

Note: While assigning text value to a variable, use quotes around the value.

In a JavaScript you do not need to explicitly declare a variable as this can be done by initializing a variable with some value. However, as a good programming style it is recommended that you declare a variable in a javaScript. Declaration of a variable in javaScript tells javaScript interpreter that the variable exists and can be referenced through out the document. Declaration of variable ensures that the program is well organized and helps to keep track of the scope of the variables in the program.
Assigning Values to Undeclared Variables
In JavaScript you can assign values to the variables that have not yet been declared. In such case variables will automatically be declared. Check out the above example once again. The statements:
y=4;
name="Kanchi";

have the same effect as:
var y=5;
var name="Kanchi";
Re-declaring Variables in JavaScript
In case you re-declare a variable in JavaScript you will not lose its original value.

E.g. Redeclaring Variables
var y=4;
var y;

In the above example y has been re-declared however it will have the value of 5. The value of y is not reset (or cleared) due to re-declaration

Comments

Really Nice Information in this blog.and Its very helpful for beginners.just you can see the reference for javascript
MLB2k11 said…
Excellent pieces. Keep posting such kind of information on your blog. I really impressed by your blog.
Vee Eee Technologies| Vee Eee Technologies|

Popular posts from this blog

Advantages and Disadvantages of EIS Advantages of EIS Easy for upper-level executives to use, extensive computer experience is not required in operations Provides timely delivery of company summary information Information that is provided is better understood Filters data for management Improves to tracking information Offers efficiency to decision makers Disadvantages of EIS System dependent Limited functionality, by design Information overload for some managers Benefits hard to quantify High implementation costs System may become slow, large, and hard to manage Need good internal processes for data management May lead to less reliable and less secure data

Inter-Organizational Value Chain

The value chain of   a company is part of over all value chain. The over all competitive advantage of an organization is not just dependent on the quality and efficiency of the company and quality of products but also upon the that of its suppliers and wholesalers and retailers it may use. The analysis of overall supply chain is called the value system. Different parts of the value chain 1.  Supplier     2.  Firm       3.   Channel 4 .   Buyer

Big-M Method and Two-Phase Method

Big-M Method The Big-M method of handling instances with artificial  variables is the “commonsense approach”. Essentially, the notion is to make the artificial variables, through their coefficients in the objective function, so costly or unprofitable that any feasible solution to the real problem would be preferred, unless the original instance possessed no feasible solutions at all. But this means that we need to assign, in the objective function, coefficients to the artificial variables that are either very small (maximization problem) or very large (minimization problem); whatever this value,let us call it Big M . In fact, this notion is an old trick in optimization in general; we  simply associate a penalty value with variables that we do not want to be part of an ultimate solution(unless such an outcome is unavoidable). Indeed, the penalty is so costly that unless any of the  respective variables' inclusion is warranted algorithmically, such variables will ...