Loading Please Wait...

Logo Lynxsia IT Solutions

JavaScript Syntax

JS Syntax

JavaScript syntax is the set of rules that described how JavaScript program shuould be written.

In HTML, JavaScript programs are executed by the web browser.

JavaScript Values

JavaScript defines two types of values that is fixed value called literals and variable value called variables.

JavaScript Literals
					 
        
          /* Literals */
          10
          10.5
          "Lynxsia IT Solutions"
          'Lynxsia IT Solutions'
        
      
JavaScript Variables

In a programming language, variables are used to store data values.

JavaScript uses the keywords var, let and const to declare variables.

An equal sign is used to assign values to variables.

					 
        
          let x;
          x = 6;
        
      
JavaScript Operators

JavaScript uses arithmetic operators ( + - * / ) to compute values.

JavaScript uses an assignment operator ( = ) to assign values to variables.

					 
        
          x = (5 * 12) / 100;
        
      
JavaScript Expressions

An expression is a combination of values, variables, and operators, which computes to a value. The computation is called an evaluation.

					 
        
          x = (5 * 12) / 100;

          x = (a * a) + (b * b) + (2 * a * b);

          firstName = "Lynxsia";
          lastName = "IT Solutions";
          fullName = firstName + " " + lastName;
        
      
JavaScript Keywords

JavaScript keywords are used to identify actions to be performed.

					 
        
          let x = 10;

          function welcome(){
            alert('Hello');
          }
        
      
JavaScript Comments

Not all JavaScript statements are "executed". Code after double slashes // or between /* and */ is treated as a comment. Comments are ignored, and will not be executed:

					 
        
          let x = 5;   // I will be executed

          // x = 6;   I will NOT be executed
        
      
JavaScript Identifiers

Identifiers are JavaScript names.

Identifiers are used to name variables and keywords, and functions.

Identifiers are used to name variables and keywords, and functions.

The rules for legal names are the same in most programming languages.

A JavaScript name must begin with:

  • A letter (A-Z or a-z)
  • A dollar sign ($)
  • Or an underscore (_)

Subsequent characters may be letters, digits, underscores, or dollar signs.

Numbers are not allowed as the first character in names.

JavaScript is Case Sensitive

All JavaScript identifiers are case sensitive.

The variables lastName and lastname, are two different variables:

JavaScript does not interpret LET or Let as the keyword let.

JavaScript And Camel Case

Historically, programmers have used different ways of joining multiple words into one variable name.

Hyphens:

first-name, last-name, master-card, inter-city.

Hyphens are not allowed in JavaScript. They are reserved for subtractions.

Underscore:

first_name, last_name, master_card, inter_city.

Upper Camel Case (Pascal Case):

FirstName, LastName, MasterCard, InterCity.

Lower Camel Case:

firstName, lastName, masterCard, interCity.

How you feel about this blog:

Share this blog on:

Report Us

If you find any error in the turtorials, or want to share your suggestion/feedback, feel free to send us email at: info@lynxsia.com

Contact Us
Ads
Logo
Lynxsia IT Solutions

We are concern with various development process like website design & development, E-commerce development, Software development, Application development, SMS & Bulk SMS Provider, PWA Development, and many more..

Kotwali Road, Chhiptehri, Banda, 210001, UP, India

Copyright © 2022, Lynxsia IT Solutions, All rights reserved