1+ //First the index.html file is loaded and then the files which are included in the header are loaded
2+ // ./ means on the same server, It represents the place where server is actually running
3+ //Browser will request index file first. The source file will be request next
4+ //Once the script file is loaded we can access variable in browser itself
5+ console . log ( "Hello World" ) ;
6+
7+ //Agenda of todays session
8+ //Variables
9+ //Objects
10+ //Functions
11+ //Combination of Objects and function
12+
13+ // Variable
14+ // Primitives -- booolean, null, number, string, undefined
15+ // Objects -- arrays, objects, dates, functions, wrappers(string, boolean, numbers)
16+
17+ // (ES5) var, (ES6)let, const
18+ // typeof -- is operator // to get the datatype of variable
19+ var num1 = 100 ;
20+ var num2 = 200 ;
21+ var num3 = num1 ; //Here the value is getting copied
22+ num1 = 150 ;
23+
24+ //Primitive type will hold its value in the memory location and for every new variable new memory location would be created.
25+
26+ var firstName = "Raj" ; //Strings can either be object or primitives
27+
28+ var b1 = true ;
29+
30+ //Undefined implies there is no value stored in the variable
31+ //When something new is created undefined is assigned to it. ??Careful with it
32+ var lastName ;
33+
34+
35+ //Objects
36+ //Arrays
37+
38+ var emp1 = {
39+ firstName :"Raj" ,
40+ lastName :"P."
41+ } ;
42+ var emp2 = emp1 ; //This is the place where emp2 referenced to emp1 memory block.
43+ emp2 . lastName = "P."
44+
45+ //Objects are "Reference"
46+ //Everything in JavaScript in an Object, Almost Everything
47+
48+ //Array
49+ console . log ( "value in error " , l1 ) ; //We get the value as undefined and not the error
50+ //This is hoisting
51+ //Allows using the name of variable before it is declared and initialized
52+ var num = [ 10 , 20 , 30 , 40 ] ;
53+ var num2 = num ;
54+
55+ // function funtion_name(function parameter/arguements){
56+ //business logic
57+ //}
58+
59+ //JS is scripting language
60+ //It work line by line
61+
62+ let l1 = [ 10 , 20 , 30 , 40 ] ; //It means for l1 the value can change.
63+ const l11 = [ 20 , 20 ] ; //It means for l11 value cannot change. constanst
64+ //const -- > value cannot be reassgined
65+ //let --> value can be reassigned
66+ //both const and let prevent hoisting
67+ //JS is loosely typed
68+ //Careful when assigning value to variables.
69+
70+ // => fat arrow notation
71+ //Assigning a function to a variable name
72+ //function are also objects and can be used as variable
73+ // const printNameES6 = () =>{§
74+ //
75+ //}
76+ //Get comfortable with basics
0 commit comments