Javascript Syntax and Basics

RSS
EMAIL
FACEBOOK
FACEBOOK
GOOGLE
GOOGLE
https://www.poftut.com/javascript-syntax-basics/
PINTEREST
PINTEREST
INSTAGRAM

In this post we will start writing simple Javascript codes and run them on the browser. We will also look comments.

Two Lines Of Code

Our code is below. It is now two line and becoming more complex but not too much for our target.

  • Here is two JavaScript line ended with ;

Comments

Writing explanations to the code is a good habit for a developer. Comments are used to add explanations to the code and Comments are not interpreted as code. They have no effect the working of code. Below we have added a comment to our single line code.

  • // used for single line comment. Only this this line is a comment
  • /* */ are used multi line comment. Between these all text are just comment

JavaScript supports writing comments or notes about code without affecting the application. Comments are very useful because it gives more details and explanation to the code.

  • This is a single line comment with //

  • This is a multiline comment. Multi-line comment starts with /* and ends with */ 

Case Sensitivity

Javascript is case-sensitive language. This means keywords, variables etc. all language elements differs with case status. Let me exlain with simple example FOR is different then for. As we see each word case is different. Keep in mind that Html is not case sensitive.

LEARN MORE  Introduction to Javascript Programming Language

Literals

Literals is data values generally used to assign numeric or string values to the variables. Below are some of literals.

Keywords

JavaScript have keywords to operate language logic. For example to loop JavaScript provides while .

Semicolons

JavaScript code lines are terminated with semicolons. Semicolons are optional but to make code readable most of the developers use semicolons in their project.

  • JavaScript code line ends with 

Adding JavaScript Code To Html Pages

For learning purposes we will use Scratchpad but in the real world JavaScript code runs in the html pages. There is two main methods to run JavaScript code in the Html page.

RSS
EMAIL
FACEBOOK
FACEBOOK
GOOGLE
GOOGLE
https://www.poftut.com/javascript-syntax-basics/
PINTEREST
PINTEREST
INSTAGRAM

Leave a Reply

Your email address will not be published.