-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path00_Hello.js
71 lines (54 loc) · 2.6 KB
/
00_Hello.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
// ----------------------------------------------
// Documentation = "https://tc39.es/ecma262/" and "https://developer.mozilla.org/en-US/docs/Web/JavaScript"
// ----------------------------------------------
console.log("Hello from Pavan!")
// Code after double slashes // or between /* and */ is treated as a comment.
// How to run the JS file? (Standalone without using index.html and adding script in it)
// node filename.js
// ----------------------------------------------
// Introduction to JS: (Reference: https://www.w3schools.com/js/default.asp)
// ----------------------------------------------
// The JavaScript syntax defines two types of values:
// 1. Fixed values = Fixed values are called Literals.
// 2. Variable values = Variable values are called Variables.
// JavaScript Literals
// The two most important syntax rules for fixed values are:
// 1. Numbers are written with or without decimals. Eg: 10.50, 1001
// 2. Strings are text, written within double or single quotes. Eg: "Hello", 'Hello'
// 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.
// Eg: var x = 5;
// JavaScript Operators
// JavaScript uses arithmetic operators (+, -, *, /) to compute values.
// JavaScript Keywords
// JavaScript keywords are used to identify actions to be performed.
// The let keyword tells the browser to create variables:
// let x = 5;
// let y = 6;
// let z = x + y;
// The var keyword also tells the browser to create variables:
// var x, y;
// x = 5 + 6;
// y = x * 10;
// NOTE:
// The var keyword was used in all JavaScript code from 1995 to 2015.
// The let and const keywords were added to JavaScript in 2015.
// The var keyword should only be used in code written for older browsers.
// When to Use var, let, or const?
// 1. Always declare variables
// 2. Always use const if the value should not be changed
// 3. Always use const if the type should not be changed (Arrays and Objects)
// 4. Only use let if you can't use const
// 5. Only use var if you MUST support old browsers.
// JavaScript Identifiers / Names
// Identifiers are JavaScript names.
// 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:
// 1. A letter (A-Z or a-z)
// 2. A dollar sign ($)
// 2. Or an underscore (_)
// 3. Subsequent characters may be letters, digits, underscores, or dollar signs.
// Note: Numbers are not allowed as the first character in names.