Facebook – https://www.facebook.com/TheNewBoston-464114846956315/
GitHub – https://github.com/buckyroberts
Google+ – https://plus.google.com/+BuckyRoberts
LinkedIn – https://www.linkedin.com/in/buckyroberts
reddit – https://www.reddit.com/r/thenewboston/
Support – https://www.patreon.com/thenewboston
thenewboston – https://thenewboston.com/
Twitter – https://twitter.com/bucky_roberts
Original source
43 responses to “Beginner JavaScript Tutorial – 25 – Creating Our Own Objects”
I am still depressed..
I'm not bothered about the age math. I think this explanation of constructor functions
Made the muddy stuff clear as crystal for me thanks a big bunch
kennel cough lmaooooo
WAIT!!. So your mom gave birth to you when she was 14?
Lovely Bucky!! Enjoyed watching ur Tutorials!!
It didn't even make any physical objects
holy feild
Couldnt you just do this?
var object1 = {
name: 'Pete',
age: '69',
};
document.write(object1.age);
I love you bucky
FYI-
'this' is only for the contextual reference of an object and can be used as a pronoun(in a way)
imagine this sentence: Bucky is a good man. Bucky likes to code….?
So in programming world, 'this' keyword provides simplicity along with what all Bucky has mentioned.
Dude you're fucking amazing. You should teach or something. I wouldn't skip a class
guyz its so easy to learn if u do not understood it see video again and again u will automatically understand this and every thing take time nothing u can learn in one day and bucky is awesome
Sorry buddy!
But just conceptually you were very wrong.
Actually what you have defined is not an object but a class. And what you are calling an "instance of an object" is actually an "instance of a class". Object is itself an "instance of a class". Not that you are teaching wrong coding. Your lectures are good. But its just that the nomenclature you just used at the end was quite wrong. Hope you can correct it now!
<!doctype.html>
<html>
<head>
<script type="text/javascript">
function a(fname,lname,age)
{
this.fname=fname;
this.lname=lname;
this.age=age;
}
</script>
</head>
<body>
<script type="text/javascript">
var x= new a("ana","cheri",28);
var y= new a("margot","robbie",28);
var z= new a("leo","messi",29);
document.write(x.fname + x.lname + x.age +"<br/>");
document.write(y.fname + y.lname + y.age +"<br/>");
document.write(z.fname + z.lname + z.age +"<br/>");
document.write(x.length+ y.length + z.length +"<br/>"); // why it's showing undefined ..??
</script>
</body>
</html>
In OOP lanaguages like Java we use classes as a way to organise similar objects, I'm just wondering how comes we can't do something like that in javascript? you can do it in PHP.
bucky's mom had bucky at 14
Bought a book on this and it confused the fuck out of me. When you explain it, I can actually follow along…Thank you Bucky
"say that and your teacher will probably get a hard on or something" lol
Is there a way to print of all the properties of an object together or we can only do them separately??
I did:
<html>
<head>
<script type="text/javascript">
function person(name, age){
this.name = name;
this.age = age;
}
var Nick = new person("Nicholas Noriega", 23);
var Taylor = new person("Taylor Swift", 20);
</script>
</head>
<body>
<script type="text/javascript">
document.write(Nick.name);
document.write(Taylor.age);
</script>
</body>
</html>
And only My name popped up as Nicholas Noriega23… How do I display two?
bucky can classes be possible in javascript??
can u teach us based on it, pls
Y do we have to do this object thing when we can do this
<script>
Function fusky(a,b){
document.write(a+"loves"+b);
}
Fusky("Bucky","Taylor");
Fusky("Bucky","Jennifer");
Fusky("Taylor","Roberts");
</script>
Hey bucky, I am wandering how do you tailor this to get the user input from a input tag?
PS: Taylor Swift is 26
How did you know all this ( biology, chemistry , c++, JavaScript …..) and you dropped the college , respect , you gave me inspiration and keep up
Function creating object!! Strange and useful!!! Thanks!!!
You should probably stop objectifying Taylor Swift. ๐
hello!, I was wondering if in the game i play, i can use this to make any item in the game?
oh wow this is awesome. I had no idea you could do Objects in javascript!
All your videos are good thanks, I appreciate it.
You're 24 and you're mom's 38 wow she's young for a mother .
it reminds me of the structure in C programming
Well explained. Thank u ๐
would you really say it is stupid to use "this" in this context? to me it's the clearest example of "this". I mean, "this" has a lot if misinterpretations, but I wouldn't say this is one of it. how would you select the current object if not?
Your mom is 38 and you are 24 ?… means 38-24=14 was her , when you spawned .
You could write computer and then just write "Doesnt have a computer" in that objects property.
I am just wondering, how do you know which codes are case sensitive? For example: If I write the array in lower case, then it won't work but writing it in upper case will? Thanks!
Guys, I rage-quited at this tutorial about 3 months ago. Now I came back to learn some stuff, but I don't remember anything I have learned about HTML, CSS and JavaScript already. lol Wish me luck cause I want to become the best JavaScript programmer in the world ๐
But how do we create new instances from outside JavaScript? Like with an HTML button?ย Is that possible?
"Either she is 20, or she will be. I don't know, good enough" haha love this! Thanks man!
Thanks, so much bro I struggle like no tomorrow learning OOP in JavaScript after learning it in PHP it's so weird and diffrent.
Bucky's mom 38??
may a say ,, your great presenter , you have a gift for – conveying information in a easy to understand manner ,, thank you for what you do ,, – Earle
Can't speak about JavaScript instructors as I'm self taught with that, but objects don't need instantiation. It's classes that need instantiation, but even if objects in JavaScript are synonymous with classes, it's to avoid confusion between the following:
"I'm going to create a new object to handle the data."
…did I just say I need a new instance to handle the data, or am I writing new code to handle the data? You don't really know, and ambiguity in programming is the fastest way to Bugsville. So:
"I'm going to create a new object…" means "I'm going to write code…"
and
"I'm going to instantiate the object…" means "I'm going to USE an object…"
There really is a reason for it beyond "giving your professor a hard on."