Monday, August 10, 2020

Syntax of Javascript How to Write javascript?

 I will give you littel introduction I want to tell you about 5 concepts:


 .white space

 .case sensitivity 

.literals 

.identifiers 

.comments


White space:

JavaScript does not consider white space meaningful. Space and lines break can be added in any fashions you might like, even though this is in theory. In practice, you will most likely keep a well-defined style and adhere to what people commonly use and enforce this using a linter or a styling tool such as Prettier.  example,  like to always 2 characters to indent. 


Case sensitive:

JavaScript is case sensitive. A variable named something is different from Something. The same goes for any identifier. 


Literals:

 We define as literal a value that is written in the source code, for example, a number, a string, boolean or also more advanced constructs, like Object Literals or Array Literals:

'Test' true

 ['a', 'b'] 

{color: 'red', shape: 'Rectangle'}


Identifiers: 

An identifier is a sequence of characters that can be used to identify a variable, a function, and object. It can start with letters, the dollar sign $ or an underscore _, and it can contain digits. Using One code, a letter can be any allowed char, for example, an emoji ß . Test test TEST _test Test1 $test The dollar sign is commonly used to reference DOM elements. Some names are reserve for JavaScript internal uses, and we can't use them as identifier.

Comments:

 Comments are one of the most important parts of any program. In any programming language. They are important because they let us annotate the code and add important information that otherwise would not be available to other people (or ourselves) reading the code. In JavaScript,  you can write a comment on a single line  //.  

// a comment 

true //another comment 


Another type of comment is a multi-line comment. 

It starts with /* and ends with */ . Everything in between is not considered as code: 

/* some kind

of comment */

No comments:

Post a Comment

The latest tech news about the world's best (and sometimes worst) hardware, apps, and much more. From top companies like Google and Apple to tiny startups ...