If you're seeing this message, it means we're having trouble loading external resources on our website.

Jeżeli jesteś za filtrem sieci web, prosimy, upewnij się, że domeny *.kastatic.org i *.kasandbox.org są odblokowane.

Główna zawartość

Teaching guide: Intro to JS - Objects

This is a teaching guide for the Intro to JS course, for the 15th unit on Objects.

Czego uczniowie się nauczą

  • How to create objects to store various related properties in one variable.
  • How to access or change properties of an object using both “bracket notation” and “dot notation”.
  • How to create arrays where each element is an object.
  • How to iterate through an array of objects using a for loop.

Uczniowie nauczą się pisać kod taki jak:

Z czym uczniowie mają kłopoty

  • Students may mess up the syntax at first - like typing ‘=’ instead of ‘:’ inside the brackets, forgetting commas after properties, or using square instead of curly brackets.
  • Students may not understand the difference between arrays and objects. They are actually quite similar, especially in JS. When they're deciding how to store their data, ask them to think about whether there is a natural sequence to the data they’re storing and if they plan to iterate through the data a lot - if so, an array is often best; if not, an object may be a better fit.
  • Students may not see the point of objects at first, because they can accomplish the same thing using multiple variables. Once their program needs to track a lot of information, however, multiple variables get quite unwieldy. Imagine if they had to store 10 properties about 20 students in the class - that’d be 200 variables without objects, but just 20 variables with objects, and just one variable using an array of objects.

Dodatkowe materiały: pytania do dyskusji

Są to pytania, które możesz zadać uczniom indywidualnie, gdy ukończą ten samouczek lub poprowadź dyskusję grupową, jeżeli każdy ukończył samouczek do tego samego momentu.
  • Some JS programmers actually create business cards that describe themselves using a JavaScript object. How would your students describe themselves with an object? Encourage them to store different types of properties, like strings, numbers, arrays, and more objects. Maybe you can even print business cards on cardstock for your students!

Dodatkowe materiały: pytania i ciekawostki

Te pytania mogą być ciekawym zajęciem po tym, jak każdy uczeń ukończył samouczek. Mogą także prowadzić dyskusję na temat pytań, które sprawiły im trudność. Zagraj z nimi na Quizizz.