ga-wdi-boston / js-objects-modeling

Other
1 stars 169 forks source link

Teaching approach #5

Closed srhoulam closed 7 years ago

srhoulam commented 8 years ago

Having seen all sorts of confusion with object literal syntax, I was wondering if it would sink in more easily with many students if we introduce objects using the Object constructor. I think this example will illustrate what I mean:

var obj = new Object();
obj.prop1 = val1;
obj.prop2 = val2;

console.log(obj.prop1); // etc.

It might be easier to get the idea of a JS object first, then learn the literal syntax afterward.

jrhorn424 commented 8 years ago

Generally in favor of introducing new Object() before {}. Interested in other's thoughts.

This would move us toward no using object literals everywhere in the initial project, and should get students thinking about the encapsulation of data and behavior sooner.

gaand commented 8 years ago

So, do we want to avoid the shorthand of "object literals" for pedagogy? This might help with the $.ajax lessons. Maybe it's okay to use var foo = {}; but don't initialize properties during the first week?

berziiii commented 8 years ago

@jrhorn424 should this be closed? I think the material is well rounded for the objectives but welcome your thoughts.

gaand commented 8 years ago

@jrhorn424 It seems to me that a discussion in progress was ended when this issue was closed. Since the issue doesn't include a conclusion, I an reopening.

@berziiii Please include me in discussions of materials. Thanks.