Advertisement
samimwebdev

Class-2(Introduction to javascript)

Dec 4th, 2021
272
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. //Data is everywhere
  2.  
  3. //const, let/var
  4. //var - Never ever use var
  5. //const, let
  6. // const firstName = 'samim' //string
  7. // const age = 28 //number
  8. // const profession = 'web developer' //string
  9. // const isProgrammer = true //boolean
  10.  
  11. // console.log(firstName, age)
  12. // console.log(
  13. //   'First Name ' + firstName + '.' + ' I am ' + age + ' I am a ' + profession
  14. // )
  15.  
  16. // console.log(`First Name ${firstName}. I am ${age}. I am a ${profession}`)
  17.  
  18. //array
  19. // const info = ['samim', 28, 'web developer', true]
  20. //length-4(start from 1)
  21. //accessing element (start from 0)
  22. // const index = info.length - 1
  23. // console.log(info[index])
  24.  
  25. // console.log(`First Name ${info[0]}. I am ${info[1]}. I am a ${info[2]}`)
  26.  
  27. //nested
  28.  
  29. //object
  30. // const userInfo = {
  31. //   firstName: 'samim',
  32. //   age: 28,
  33. //   profession: 'web programmer',
  34. //   fullName: function () {
  35. //     console.log(this.firstName)
  36. //   },
  37. //   isProgrammer: true,
  38. //   random1: [1, 2, 3, 5],
  39. //   random2: {
  40. //     greet: 'hello'
  41. //   }
  42. // }
  43.  
  44. // userInfo.fullName()
  45.  
  46. // const myAge = 'age'
  47.  
  48. // console.log(userInfo[myAge])
  49.  
  50. // console.log(userInfo.age)
  51. // console.log(userInfo['age'])
  52.  
  53. // console.log(userInfo.random1[3])
  54. // console.log(userInfo.random2.greet)
  55.  
  56. // console.log(
  57. //   `First Name ${userInfo.firstName}. I am ${userInfo.age}. I am a ${userInfo.profession}`
  58. // )
  59.  
  60.  
  61.  
  62.  
  63.  
  64. //Introduction to Function(code reuse)
  65.  
  66. // function showInfo(num1, num2) {
  67. // console.log(num1, num2)
  68. //function body
  69. //   return num1 + num2
  70. // }
  71.  
  72. // console.log(showInfo(10, 5))
  73.  
  74. // console.log(3 + 5)
  75. // console.log(10 + 5)
  76. // console.log(10 + 5)
  77. // console.log(10 + 5)
  78. // console.log(10 + 5)
  79. // console.log(10 + 5)
  80. // console.log(10 + 5)
  81.  
  82.  
  83.  
  84.  
  85.  
  86. // function showBio(userInfo) {
  87. //   return `First Name ${userInfo.firstName}. I am ${userInfo.age}. I am a ${userInfo.profession}`
  88. // }
  89.  
  90. // const info = {
  91. //   firstName: 'samim',
  92. //   age: 28,
  93. //   profession: 'web programmer',
  94. //   isProgrammer: true,
  95. //   random1: [1, 2, 3, 5],
  96. //   random2: {
  97. //     greet: 'hello'
  98. //   }
  99. // }
  100.  
  101. // console.log(showBio(info))
  102.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement