-
Notifications
You must be signed in to change notification settings - Fork 0
/
1.js
29 lines (24 loc) · 999 Bytes
/
1.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
URL = 'https://hplussport.com/api/products'
var request = new XMLHttpRequest(); // Create Request
request.open('GET', URL); // Open Request
request.onload = function() { // Action once data received
var response = request.response; // Get Response
console.log(typeof response); // Check Type of Response --> String
var jsonData = JSON.parse(response); // Parse to JSON
console.log(typeof jsonData); // Check Type of Response --> Object
};
request.send(); // Send Request
var car = { // Create Object car
make: "Honda", // String property
model: "City",
year: 2014, // Number property
honk: function() { // Function property
alert("Beep beep"); // Alert command
},
driver: { // Object property
name: "Allen",
license: "TN"
}
};
console.log(car.make); // Log property make of object car
console.log(car.driver.name); // Log property name of object driver of object car