0

objects in JavaScript

i can't make objects with javascript, even tough i copy it all from the sololearn examples, anyone can help???

9th Jan 2020, 7:14 PM
NIR DERI
NIR DERI - avatar
6 ответов
+ 6
Do you mean Js objects or DOM objects like "<div>","<a>"...?
9th Jan 2020, 7:35 PM
Kevin ★
+ 2
Do you have an example of what is not working correctly that you could provide? Edit: added in NIR DERI ‘s example. js: var person={ name: "John", age: 31, favColor: "green", height: 183 }; html: <html> <head> <title>not_working_objects</title> <script src="java/introducing_objects.js"></script> </head> <body> </body> </html> Currently if you were to load this webpage nothing would happen. To YOU at least. To the webpage, it just stored an object that has about 4 properties attached to it in the background. It didn’t notify you about it because you didn’t do anything with it. You said this doesn’t work, however you would have little way of checking if it did work unless you went and typed in person.name into the console or something. Try adding console.log(person.name); after the object is made.
9th Jan 2020, 7:32 PM
Pie
Pie - avatar
+ 2
9th Jan 2020, 7:51 PM
Yaroslav Vernigora
Yaroslav Vernigora - avatar
+ 1
let myObjectCar = { model: 'Audi', color: 'white', price: '5000
#x27; } console.log(myObjectCar.price)
9th Jan 2020, 7:46 PM
Yaroslav Vernigora
Yaroslav Vernigora - avatar
9th Jan 2020, 8:01 PM
Yaroslav Vernigora
Yaroslav Vernigora - avatar
0
js: var person={ name: "John", age: 31, favColor: "green", height: 183 }; html: <html> <head> <title>not_working_objects</title> <script src="java/introducing_objects.js"></script> </head> <body> </body> </html>
9th Jan 2020, 7:45 PM
NIR DERI
NIR DERI - avatar