JavaScript is a client-side scripting language or browser scripting language.Client side language means that the browser will run/execute these scripts.At this moment JavaScript also can run in server side by Node.js.

*Java and JavaScript are completely two different languages.Many aspects of JavaScript,specially syntax,are borrowed from Java,but to learn JavaScript you do not need to know Java or any language in advance.

**JavaScript is basically made up of 3 things such as

1)ECMAScript(this is the core functionality of JavaScript)

2)DOM(Document Object Model-works with web page content) 

3)BOM(Browser Object Model-works with the browsers)

Javascriipt can be used to create a variety of effects or interesting things on an HTML page,as well as form validation and ajax work.Among the most well-known works for web pages

Toggle button Mouse Trailers(animation created on the mouse while browsing the site) Alert message Popup window Images Slideshow Zooming in or zooming out on an image Displaying a timer or count-down on a website Playing audio and video in a web page Displaying animations Using a drop-down hamburger menu Form validation Many more Note: Before learning javascript,you atleast have to have some basic knowledge of HTML and CSS.

B.How to write javascript(JS syntax)
we already know that javascript code is written inside HTML code.Code can be written using the <script> element or tag.Even if you use external javascript,you have to connect it with this element.You have to enter javascript in an HTML document as below


The <script> tag ends with </script> tag.Many attributes can be used in <script> tag.The most commonly used are "src" and "type".The src attributes is used to connect external files and the type attributes usually uses the value "text/javascript" meaning type="text/javascrtipt".
There are more attributes,but all attrubutes will only work if <script></script> is not optional.For instance, with async,any work on the web page can be fixed so that it does not stop or you do not have to delay the script load.This only applies to external files.There are attributes like charset,defer etc. but they are not commonly used or no need to used.
**If deferred,the page will laod before it is complete,then it is complete ,then javascript will be exacuted.It is also used only in the case of external javascript.You have write like this in below


***<noscript></noscript> Element
if the browser does not support javascript or hte borwser has javasript disabled ,the content inside this noscript element will show up in the browser.Any HTML element can be placed inside <noscript></noscript>.
you can put hte element inside <body></body> tag .Look down picture

**try disabling javascript in your browser.Content inside <noscript> will show up in the browser.If javascript is enabled in the browser ,nothing inside <noscript> will show in the browser.
**In javascript we have to concatenate two strings with a plus (+) sign .Look picuture below

The is best platform to learn javascript.
**Each javascript line must end with semicolon(;) but is not mandatory.

**Adding a number and a string will treat the javascript number as a string and output as follows.
The number is 8.

JavaScript Enable in browser

In this chapter I will show you how to activate JavaScript in Internet Explorer, Firefox, and Opera.

How to enable JavaScript in Internet Explorer:

In Internet Explorer 6/7 you can go to security settings and check if your JavaScript is active. Below is the way to activate JavaScript.

1 First you have to click on the Tools menu

From the menu, then Internet Options must be selected

3  Click on the Security tab of Internet Options

4 Then click on the Custom Level button to enter the security settings

5 Scroll to the Scripting section

6 And  script mobilize to Select the Enable button

Click OK button to complete the process

8 for the Yes button Click to

How to enable JavaScript in Firefox:

In Firefox 2 you can go to the Content setting of Options and check if your JavaScript is enabled. Below is the way to activate JavaScript.

1 First you have to click on the Tools menu

2 Then you have to select Options from the menu

Click on the Content tab of 3  Options

4 Make sure the Enable JavaScript check box is checked

5 Click on OK button to complete the process

How to enable JavaScript in opera:

In Opera, you can go to the Content setting of Preferences and check if your JavaScript is active. Below is the way to activate JavaScript.

1 First you have to click on the Tools menu

2 Then select Preferences from the menu

Click on the Advanced tab of 3 Preferences

4 You have to select the content from the list item on the left side

5 Make sure the Enable JavaScript check box is checked

Click OK button to complete the process

Where To Place Javascript Code
There are three common locations where JavaScript code can be kept. 1)Inside the head tag 2) Inside body tags 3)As an external file It is very common to choose the position of head or body. If you want JavaScript to run on certain events (such as when a user clicks on a place, the event is discussed) you can put JavaScript in the head tag. Again, if you want to run JavaScript when the page loads (like the "Hello World!" Example in the previous chapter), you can put JavaScript in the body tag. External JavaScript files and their usage are discussed in the next chapter.

External JavaScript IN DETAILS

The position of JavaScript in the head and body tags of HTML documents is discussed in the previous chapter. Now we will discuss about the third position which is external javascript file. Rules for importing external JavaScript files : Hacking external JavaScript file is a hassle-free task. Firstly, the file that you will import must be valid and only be a JavaScript file. Secondly, the file extension must be ".js". Finally, you must know the location of the file. Let's say we have a file called "myjs.js" which contains the one-line alert function called Hello World. Let's assume that the HTML file and the JavaScript file are in the same directory.

Way to assign variables in Javascript

javascript data types

Post a Comment