| Number | Rider | Time | | 1 | Bullet Bob | 56:07 | | 2 | Clumsy Colin | DNF | | 3 | Swift Susan | 55:13 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"use strict"; | |
let user = { name : "Jagathish" }; | |
Object.isExtensible(user); // true | |
Object.preventExtensions(user); | |
Object.isExtensible(user); // false |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"use strict"; | |
let user = { name : "Jagathish" }; | |
Object.preventExtensions(user); | |
try { | |
user.age = 23; | |
} catch (e) { | |
console.log(e); | |
// expected output: TypeError:Cannot add property age, object is not extensible |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"use strict"; | |
let user = { | |
name : "Jagathish", | |
age : 23, | |
mobile : 123123123, | |
address : "221B Baker Stree, London" | |
}; | |
let handler = { | |
set(target, prop, val){ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let target = {}; | |
let handler = {}; // empty handler | |
let proxy = new Proxy(target, handler); | |
proxy.test = 5; // the property will be added in target | |
target.test; // 5 | |
proxy.test; // 5 | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let target = { | |
name : "Mia", | |
age : 28 | |
}; | |
let handler = { | |
get(targetObject, propertyName) { | |
if( propertyName in targetObject) { | |
return `The ${propertyName} is ${targetObject[propertyName]}`; | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let fileInput = document.getElementById('file_chooser'); | |
fileInput.addEventListener('change', function(e) { | |
var file = this.files[0]; | |
var fd = new FormData(); | |
fd.append("file", file); | |
var request = new XMLHttpRequest(); | |
request.open('POST', 'http:myserver.com/upload'); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let fileInput = document.getElementById('file_chooser'); | |
fileInput.addEventListener('change', function(e) { | |
var file = this.files[0]; | |
var fd = new FormData(); | |
fd.append("file", file); | |
var request = new XMLHttpRequest(); | |
request.open('POST', 'http:myserver.com/upload'); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let url = "https://medium.com/search?q=javascriptjeep"; | |
let request = new XMLHttpRequest(); | |
console.log(request.readyState); // 0 | |
//after calling open the state will be changed to 1 | |
request.open("GET", url); | |
console.log(request.readyState); // 1 | |
// we need to implement readystatechange event to detect 2,3,4, events | |
request.onreadystatechange = function() { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
request.onprogress = function(e) { // triggers periodically | |
/* | |
e.loaded - how many bytes downloaded | |
e.lengthComputable = true if the server sent Content-Length header, if true we can find the size of the response | |
e.total - total number of bytes (if lengthComputable is true) | |
*/ | |
let total = e.lengthComputable ? e.total : 0; | |
let loaded = e.loaded; | |
if(total) { |