Js fundamentals part 1 Modern Javascript


Download 1.18 Mb.
Pdf ko'rish
bet1/4
Sana13.09.2023
Hajmi1.18 Mb.
#1676711
  1   2   3   4
Bog'liq
JS FUNDAMENTALS PART 1



JS FUNDAMENTALS PART 1
Modern Javascript


In Javascript there are legal and illegal ways of naming a variable:
Legal way:
Must begin with a letter, underscore (_), or dollar sign ($).


Can contain letters, numbers, underscores, or dollar signs.
Are case sensitive, meaning that "myVar" and "myvar" are two different
variables.
Should not use reserved keywords, such as "var", "function", "if", "else",
"while", "for", etc.
Illegal variable names:
Cannot begin with a number.
Cannot contain spaces or special characters (except underscore or dollar
sign).
Cannot use reserved keywords.
Cannot start with Capital letters.


CamelCase is reccomended to use in Js => myFullname, isMarried...
const PI = 3.14; This variable works only in this case.
Naming variables must be descriptive:
const myFirstName = "Mirjalol"; 
cosnt myFirstJob = "Teacher"
Data Types
Variables that hold a value can be data type, not variable.


Comments in Js


This is multiline way of commenting 
Single line way of commenting 
let, var and const


let can be reassigned, mutated. 
let book = "Alvido Vatan"; 
book = "Halol Luqma"; 

let cannot be redaclared
let myFirstJob = "Teacher"; 
let myFirstJob = "Programmer";

You can create Undefined variable with let. 
let code;

Reccomanded one is const
variables that doesnt change are declared with const, u cannot reassign and
redaclare

Download 1.18 Mb.

Do'stlaringiz bilan baham:
  1   2   3   4




Ma'lumotlar bazasi mualliflik huquqi bilan himoyalangan ©fayllar.org 2024
ma'muriyatiga murojaat qiling