পৃষ্ঠাসমূহ
Labels
Search Your Article
CS
Pageviews
Showing posts with label Javascript Basics Tutorial. Show all posts
Showing posts with label Javascript Basics Tutorial. Show all posts
Thursday, March 23, 2017
JavaScript - Syntax
JavaScript can be implemented using JavaScript statements that are placed within the <script>... </script> HTML tags in a web page.
You can place the <script> tags, containing your JavaScript, anywhere within your web page, but it is normally recommended that you should keep it within the <head> tags.
The <script> tag alerts the browser program to start interpreting all the text between these tags as a script. A simple syntax of your JavaScript will appear as follows.
You can place the <script> tags, containing your JavaScript, anywhere within your web page, but it is normally recommended that you should keep it within the <head> tags.
The <script> tag alerts the browser program to start interpreting all the text between these tags as a script. A simple syntax of your JavaScript will appear as follows.
Enabling JavaScript in Browsers
All the modern browsers come with built-in support for JavaScript.
Frequently, you may need to enable or disable this support manually.
This chapter explains the procedure of enabling and disabling JavaScript
support in your browsers: Internet Explorer, Firefox, chrome, and
Opera.
JavaScript - Placement in HTML File
There is a flexibility given to include JavaScript code anywhere in
an HTML document. However the most preferred ways to include JavaScript
in an HTML file are as follows −
- Script in <head>...</head> section.
- Script in <body>...</body> section.
- Script in <body>...</body> and <head>...</head> sections.
- Script in an external file and then include in <head>...</head> section.
JavaScript - Variables
JavaScript Datatypes
One of the most fundamental characteristics of a programming language is the set of data types it supports. These are the type of values that can be represented and manipulated in a programming language.JavaScript allows you to work with three primitive data types −
JavaScript - Operators
What is an operator?
Let us take a simple expression 4 + 5 is equal to 9. Here 4 and 5 are called operands and ‘+’ is called the operator. JavaScript supports the following types of operators.- Arithmetic Operators
- Comparision Operators
- Logical (or Relational) Operators
- Assignment Operators
- Conditional (or ternary) Operators
JavaScript - if...else Statement
While writing a program, there may be a situation when you need to
adopt one out of a given set of paths. In such cases, you need to use
conditional statements that allow your program to make correct decisions
and perform right actions.
JavaScript supports conditional statements which are used to perform different actions based on different conditions. Here we will explain the if..else statement.
JavaScript supports conditional statements which are used to perform different actions based on different conditions. Here we will explain the if..else statement.
JavaScript - Switch Case
You can use multiple if...else…if statements, as in the
previous chapter, to perform a multiway branch. However, this is not
always the best solution, especially when all of the branches depend on
the value of a single variable.
Starting with JavaScript 1.2, you can use a switch statement which handles exactly this situation, and it does so more efficiently than repeated if...else if statements.
Starting with JavaScript 1.2, you can use a switch statement which handles exactly this situation, and it does so more efficiently than repeated if...else if statements.
JavaScript - While Loops
While writing a program, you may encounter a situation where you need
to perform an action over and over again. In such situations, you would
need to write loop statements to reduce the number of lines.
JavaScript supports all the necessary loops to ease down the pressure of programming.
JavaScript supports all the necessary loops to ease down the pressure of programming.
JavaScript - For Loop
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.
JavaScript for...in loop
The for...in loop is used to loop through an object's
properties. As we have not discussed Objects yet, you may not feel
comfortable with this loop. But once you understand how objects behave
in JavaScript, you will find this loop very useful.
JavaScript - Loop Control
JavaScript provides full control to handle loops and switch
statements. There may be a situation when you need to come out of a loop
without reaching its bottom. There may also be a situation when you
want to skip a part of your code block and start the next iteration of
the loop.
JavaScript - Functions
A function is a group of reusable code which can be called anywhere
in your program. This eliminates the need of writing the same code again
and again. It helps programmers in writing modular codes. Functions
allow a programmer to divide a big program into a number of small and
manageable functions.
JavaScript - Events
What is an Event ?
JavaScript's interaction with HTML is handled through events that occur when the user or the browser manipulates a page.When the page loads, it is called an event. When the user clicks a button, that click too is an event. Other examples include events like pressing any key, closing a window, resizing a window, etc.
JavaScript and Cookies
What are Cookies ?
Web Browsers and Servers use HTTP protocol to communicate and HTTP is a stateless protocol. But for a commercial website, it is required to maintain session information among different pages. For example, one user registration ends after completing many pages. But how to maintain users' session information across all the web pages.JavaScript - Page Redirection
What is Page Redirection ?
You might have encountered a situation where you clicked a URL to reach a page X but internally you were directed to another page Y. It happens due to page redirection. This concept is different from JavaScript Page Refresh.There could be various reasons why you would like to redirect a user from the original page. We are listing down a few of the reasons −
JavaScript - Dialog Boxes
JavaScript supports three important types of dialog boxes. These
dialog boxes can be used to raise and alert, or to get confirmation on
any input or to have a kind of input from the users. Here we will
discuss each dialog box one by one.
JavaScript - Void Keyword
void is an important keyword in JavaScript which can be used
as a unary operator that appears before its single operand, which may be
of any type. This operator specifies an expression to be evaluated
without returning a value.
JavaScript - Page Printing
Many times you would like to place a button on your webpage to print
the content of that web page via an actual printer. JavaScript helps you
to implement this functionality using the print function of window object.
The JavaScript print function window.print() prints the current web page when executed. You can call this function directly using the onclick event as shown in the following example.
The JavaScript print function window.print() prints the current web page when executed. You can call this function directly using the onclick event as shown in the following example.
JavaScript - Objects Overview
JavaScript is an Object Oriented Programming (OOP) language. A
programming language can be called object-oriented if it provides four
basic capabilities to developers −
- Encapsulation − the capability to store related information, whether data or methods, together in an object.
- Aggregation − the capability to store one object inside another object.
- Inheritance − the capability of a class to rely upon another class (or number of classes) for some of its properties and methods.
Subscribe to:
Posts (Atom)