Advertisement
samimwebdev

class-2 -Introduction to Javascript

Feb 15th, 2022
204
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. Let's Talk to Computer
  2. // Everything is data....
  3. // I am samim, I am 30, I am a programmer
  4.  
  5. //Checking data type
  6. // I
  7. // am
  8. // samim
  9. // 30
  10. // a
  11. // programmer
  12.  
  13.  
  14. // Declaring variable
  15. //  *Rules- camelCasing, pascalCase
  16. //  let, var, const
  17. // Javascript Data type
  18. //  primitive
  19. //   - string
  20. //   - number
  21. //   - boolean(true, false)
  22. //   - undefined
  23. //   - null
  24. //   - Symbol
  25. //   - Bigint
  26.  
  27.  
  28. //  Object/complex data type
  29. //   - array
  30. //   - object
  31. //   - function
  32.  
  33.  
  34. //labelling data(variable)/container
  35. //naming variable
  36. // Variable names cannot contain spaces.
  37. // Variable names must begin with a letter, an underscore (_) or a dollar sign ($).
  38. // Variable names can only contain letters, numbers, underscores, or dollar signs.
  39. // Variable names are case-sensitive.
  40. // special (reserved keyword array not allowed)
  41.  
  42. //var,let,const
  43. // const firstName = 'samim' //string (anything  wrapped in single or double quote
  44. // const age = 3 //number
  45. // var profession = 'programmer'//(Don't use)
  46.  
  47. //always declare with const
  48.  
  49. //data type
  50. //primitive
  51. const firstName = 'samim' //string
  52. const age = 3 //number
  53. const isDeveloper = true //(boolean)
  54. const isMachineEngineer = undefined //(Never use)
  55. const isDesigner = null
  56. // const randValue = Symbol() //generate unique value
  57. // const bigNum = 1212313n //bigint
  58.  
  59. //complex/object data type
  60. //array
  61. // const person = ['samim', 30, true, null]
  62. // console.log(person[0], person[1])
  63.  
  64. const personObj = {
  65.   name: {
  66.       first: 'samim',
  67.       last: 'Hasan'
  68.   },
  69.   age: [30, 40, 20],
  70.   isDeveloper: true,
  71.   isDesigner: null,
  72. }
  73.  
  74. //object
  75. personObj.name.first = 'anis'
  76. personObj.location = 'Dhaka'
  77. console.log(personObj)
  78. //accessing property /key
  79. console.log(personObj.name.first)
  80. console.log(personObj['firstName'])
  81. console.log(personObj.age[2])
  82. console.log(personObj.isDeveloper)
  83.  
  84.  
  85. //function
  86. //will be discussed later
  87.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement