Advertisement
samimwebdev

Orientation and javascript overview

Jun 10th, 2022
217
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <!-- Javascript primer:
  2.     Declaring variable
  3.     Data Type:
  4.         primitive
  5.             string: 'hi', "hello"
  6.             number: 10, 10.34 , -2 , -2.345
  7.             boolean: true, false
  8.             undefined : undefined
  9.             null: null
  10.             Symbol- Symbol('address') !== Symbol('address')
  11.             BigInt
  12.         complex data type
  13.             object - {}
  14.             array- []
  15.             function
  16.  
  17. Things to get ready
  18. Loop:
  19. while loop
  20. For Loop
  21. For of Loop
  22. For in Loop
  23.  
  24. Checking data on object
  25.  
  26. understanding function
  27.  
  28. conditionals and ternary -->
  29.  
  30.  
  31. //var, let, const
  32. // var firstName = 'samim' // should avoid this
  33. // let lastName = 'Hasan'
  34. // const email = 'samimfazlu@gmail.com'
  35.  
  36. // lastName = 'fazlu'
  37. // console.log(lastName)
  38.  
  39. // const fName = 'samim'
  40. // console.log(typeof fName)
  41.  
  42. // console.log(Symbol('address') === Symbol('address'))
  43.  
  44. // const obj = {
  45. //   name: 'samim',
  46. //   age: 30,
  47. // }
  48.  
  49. // console.log(obj.name)
  50. // obj.name = 'Khalil'
  51. // console.log(obj['name'])
  52. // obj.profession = 'software Developer'
  53. // console.log(obj)
  54.  
  55. // const arr = ['samim', 30, 'programmer']
  56. //             // 0          1    2
  57. // console.log(arr[0])
  58. // console.log(arr[arr.length - 1])
  59.  
  60. //loop
  61. //for loop
  62. //while
  63. //do while(X)
  64.  
  65. // for(let i = 0; i < 10; i++){
  66. //     console.log(i)
  67. // }
  68.  
  69. // let i = 0
  70. // while (i < 10) {
  71. //   console.log(i)
  72. //   i++
  73. // }
  74.  
  75. //looping array
  76. // const arr = ['samim', 30, 'programmer']
  77.  
  78. // for(let i = 0; i < arr.length; i++){
  79. //     console.log(arr[i])
  80. //     console.log(i)
  81. // }
  82.  
  83. //for of loop
  84. // for(let elm of arr ){
  85. //     console.log(elm)
  86. // }
  87.  
  88. //object looping
  89. // const obj = {
  90. //   name: 'samim',
  91. //   age: 30,
  92. // }
  93.  
  94. // console.log('name' in obj)
  95. //for in loop
  96.  
  97. // for(let key in obj){
  98. //     console.log(obj[key])
  99. //     console.log(key)
  100. // }
  101.  
  102. //conditional
  103. // const age = 14
  104. // if (age > 18) {
  105. //   console.log('you can vote')
  106. // } else {
  107. //   console.log('you cant vote')
  108. // }
  109.  
  110. // //ternary operator
  111. // const result = age > 18 ? 'you can vote': 'you cant vote'
  112. // console.log(result)
  113.  
  114.  
  115.  
  116.  
  117. // 50, 60
  118. // 50 + 60 = 110
  119. // 110 / 2 = 55
  120.  
  121.  
  122. // function avg(num1, num2){
  123. //     const total = num1 + num2
  124. //     const result = total /2
  125. //     return result
  126. // }
  127.  
  128. // console.log(avg(50, 60))
  129. // console.log(avg(110, 120))
  130.  
  131.  
  132. //nested loop
  133. // for(let i = 0; i < 3; i++){
  134. //     for(let j = 0; j < 3; j++){
  135. //         console.log(i, j)
  136. //     }
  137. //     console.log(i)
  138. // }
  139.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement