Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

JavaScript Using jQuery Plugins Introducing jQuery Plugins Exploring Plugin Options

Yixi Guan
Yixi Guan
7,927 Points

Where to learn more about object literal?

I don't quite understand object literal in the video. Dave said he would put a link in the teacher's note, but I didn't find it.

Does anybody know which video has a better explanation about object literal? Could you share the link?

Thank you.

4 Answers

Hey Yixi,

You could try having a look at the documentation here: https://learn.jquery.com/code-organization/concepts/ . I find that doing a google search really helps, I do this all the time when I get an unexpected error or need more more information when I am writing code. Hope this helps.

Regards,

Richard.

that link is unhelpful

Yixi Guan
Yixi Guan
7,927 Points

I took this course already, but I guess I didn't pay enough attention to the details. Thank you. I will review the object part again.

ur rude laird

Dennis Le
Dennis Le
12,872 Points

Not sure this will help you. I notice you already saw the videos. So I give it a try to explain...

In javascript, there are many ways to create an object. var car = new Object();

var car = { }; console.log(car); / Object

When javascript(Js) engine runs it is parsing the syntax, it come across this curly brace and equal operator = { }, it will know you are creating an object. You can initialize the object. You can set up properties and methods all in the curly braces on what is treated as one line of code.

-there is two properties on the car object... -make and model are known as key... put them together they are known as property... -Honda and Accord are known as value.... -the value of the property can be string, number , Boolean, another object, and array...

var car = {

    make : Honda,
    model : Accord
};

console.log(car); / /Object {brand: ‘Honda’, model : ‘Accord’ }

Let create a functions....and got deeper

The function will expect an object that has make property (created earlier), so I can call ride and pass in car

function ride(drive){
    console.log(I have a  + drive.make);
}
ride(car); //"i have a Honda"

-call ride and pass in car -car is sitting in memory….than it get pass to the function and it able to be used -drive.make...

ride(car);

Daniel Mitchell
Daniel Mitchell
5,834 Points

These guys go really in depth if you want to really dive into it!

https://www.youtube.com/watch?v=pKJG6u2kuFw