Blog Day 3: Object

Inseo Park·2021년 7월 9일
0

Path to Data Scientist

목록 보기
2/58
  1. TIL (Things I learned today)
  • Object (객체) is what I learned today in javascript. Objects consist a key and a value. Which is a better way than array when in different data sets where there are same groups of keys but different values. Uh. I am really bad in explaining what object is a javascript. I will use an example.
    firstName = 'Inseo',
    lastName = 'Park';
    firstName2 = 'Zac',
    lastName2 = 'Lee';
    Now if this is a data set, and you have to process more than a hundred first names and last names, this will lead to a too much of a data which makes using object as a type of data very efficient. Using object,
    You can tie each data using a user name.
    User1 = {
    firstName = 'Inseo',
    lastName = 'Park'
    }
    User2 = {
    firstName = 'Zac',
    lastname = 'Park'
    }
    This way it is much more efficient and you can add different keys and values into the User you want to and process each user and compare it to another user.

  • There are two different ways you can approach a value in an object.
    A. Dot notation

  • Dot notation ex. user.firstName; // 'Inseo'
    user2.firstName; // 'Zac'
    B. Bracket notation

  • Bracket notation ex. user['firstName'] // 'Inseo'
    user2['firstName'] // 'Zac'

  • Now the difference between this two is that you will have a certain situation where you have to use bracket notation. When the 'key name' changes from time to time, you have to use bracket notation. For example, when you want to make a function that continously finds the value in a variable key, you have to use bracket notation to make the function usable in any situation.
    If user[variableKeyName] is used, then when variableKeyName = firstName at first and lastName at second. Using the bracket notation will lead to the function to find 'Inseo' at first and 'Park' at the second attempt. Simply, you have to use bracket notation when the key name varies from time to time.

  • You can add value in an object by using
    ex. user['age'] = '39' // user { firstName = 'Inseo', lastName = 'Park', age = '39' }

  • You can delete value in an object
    ex. delete user.firstName;
    delete user['age'];

  • You can check if an object contains a key.
    ex. 'content' in user // false
    'age' in user // true

  • When you meet an error while programming or coding, do not just ignore it but try to read over it.

  • Life will give you failures and pain but don't put any mind on that, without any failures you will not become happy nor successful

  • Being thankful for really little things is a key to moving on everyday with happiness.

  1. 3 Things to be Thankful For
  • I am thankful for being able to come to this time in the evening without any hurt or pain
  • I am thankful for being able to write my blog today.
  • I am thankful for a good friday and for God taking care of me throughout the past weekdays.
  1. New Ideas or Things to Think About
  • What is let keys in key2?
  • What is the best way to overcome covid-19, London's way to overcome covid is to accept covid as a normal flu we all have in this world. Vaccinate a lot of people and just focus on lowering death due to covid and find a cure to covid patients. We can't fully destroy covid or remove covid from the world.
  • Why do I want to buy a bicycle when I can run. I don't feel happy in running, what is in my mind that I want to buy a bicycle. Am I really bored of running or is it just that I want to get something new to refresh my mind.
  • I want to learn how to keep my key low and not boast about my progress because it makes me less motivated and less humble which is a minus for me in my hustlin progress.
profile
my journey to become a data scientist.

1개의 댓글

comment-user-thumbnail
2021년 7월 10일

화이팅입니다!

답글 달기