Let's discuss a client-side scripting language. When you try to access some information, which is stored in a server, anywhere in the world. You receive the information from there, that you see on the computer screen because JavaScript code runs on your machine, inside the internet browser. For example, you order food online. A delivery boy comes to deliver it. You don't interact with the kitchen where the food is prepared. You just receive the food. Another example, you click a link or enter URL in the address bar to access a website, a request goes to the server. Then, a response comes from the server and you see the website in your browser.
1. The Server (installed anywhere in the world)
2. The Client (your browser)
Client-side scripting - It runs in your web browser. When you request some information, that request is sent to the server, and then you access the requested information in your web browser.
Server-side scripting - It directly runs on the server. When you request some information, that request is not sent anywhere. You directly interact with the server, which shows you the requested information.
JavaScript can validate forms. For example, a user has to enter some mandatory details like address, name, phone number etc. The form will not be submitted until all the mandatory fields are filled by the user.
It can add functionality to your web page. For example, you can add a countdown timer, or change the background color of one particular paragraph when you hover over the paragraph.
Communication with the server. For example, when you use twitter, Facebook, LinkedIn etc. There a few posts or images on your screen. Next, you scroll down to see more items. The more content does not load until you scroll down. When you scroll down, the request is sent to the server. Then, JavaScript fetches and shows more items to you.
A high-level programming language - JavaScript is independent of your computer's hardware architecture. Easy to understand, and can be used on any platform. It does not talk about your computer’s hardware like memory, processing power etc. Its entire focus on the programming logic, which makes it more user-friendly and machine independent language.
Interpreter - An interpreter is a program, which converts JavaScript to the machine code that your computer understands. Almost all browsers support it. Your browser understands JavaScript because it has got JavaScript Interpreter. When the browser finds it in a web (HTML) page, it asks the Interpreter to read and interpret the code.
Is it interpreted or compiled? - Computers can directly not talk to us because they understand only numbers. We need a translator to communicate with computers. That's why we need to use interpreters and compilers. "Interpreted" means that it has got an interpreter, which provides the real-time and sentence-by-sentence translation. When you run JavaScript code, at the same time it is translated into machine language that your computer can understand. There is no intermediate file when we use interpreter. On the other hand, if you talk about compiled implementation. It scans and analyses the whole source code, then translates it into machine code. It does not do sentence-by-sentence translation. It translates as a whole into machine code. Compiler reads entire program, then compiles it. There is an intermediate code when we use Compiler. It is very difficult to decide that JavaScript uses Interpreter or Compiler because recently some controversies have erupted around this topic. I would say that you need to look at the various scenarios where you are going to use it.
When we end - (closing tag) - </>
Statements are placed within the <script> </script> tags.
You can write the tags multiple times for multiple statements.
You can write codes in different ways. For example, I am using an HTML file. I can write codes directly in the HTML file.
<!DOCTYPE html >
<html>
<head>
</head>
<body>
<script type=”text/JavaScript”>
document.write("awesome world by Tech N Toast");
</Script>
</body>
</html>
Sample output will look like this: awesome world by Tech N Toast.
Where "type" is an attribute, and its value is ""text/JavaScript". It means that this is JavaScript. You can write the code in the head section or in the body section of you HTML file. Add several codes if required.
======================
Or write the code in a separate file, and then mention this file in my HTML page.
For example, I create a separate JavaScript file, and name it "neeraj.js".
< !DOCTYPE html >
<html>
<head>
</head>
<body>
<script type="text/JavaScript" src="neeraj.js"></script>
</body>
</html>
where src means "source" and "neeraj.js" is your file name. Please make sure that the extension of the file is ".js". You can add several files. It is always good to put the JavaScript file and the HTML file in the same folder. If your JavaScript file is in different folder, you need to mention the full path ( <script src="/js/neeraj.js"></script>) instead of the file name.
External scripts do not contain the <> </> tags, just write your code - document.write("awesome world by Tech N Toast"); and save it. There should not be any script tags in such external files. You will get a syntax error if you include them.
Extraordinary document... Awesome..
ReplyDeleteWow! Thanks Suri.
Deletegood notes please do few more about plugins in ms crm
ReplyDelete