class extends
class className extends otherClassName{ // code }
Here is what the above code is Doing:
1. We’re creating a new class called className.
2. We’re making className inherit from otherClassName.
3. We’re defining the class.
class className extends otherClassName{ // code }
Here is what the above code is Doing:
1. We’re creating a new class called className.
2. We’re making className inherit from otherClassName.
3. We’re defining the class.
const randomArrayInRange = (min, max, n) => Array.from({ length: n }, () => Math.floor(Math.random() * (max – min + 1)) + min); // Example randomArrayInRange(1, 100, 10); Here is what the above code is Doing: 1. We create an array of length n. 2. We fill the array with random numbers in the range min…
const func = () => {}; // Or const func = Function(); Here is what the above code is Doing: 1. We’re creating a function called func. 2. We’re assigning it to a variable called func. 3. We’re calling the function.
delete myObj[“SomeProperty”]; delete myObj.SomeProperty; Here is what the above code is Doing: 1. We create an object called myObj. 2. We add a property called SomeProperty to myObj. 3. We delete the SomeProperty property from myObj. Note that we can use either dot notation or bracket notation to delete a property. Instructions Delete the property…
// Copies the image as a blob to the clipboard (PNG only) navigator.clipboard.write([ new window.ClipboardItem({ [blob.type]: blob, }), ]) Here is what the above code is Doing: 1. Create a canvas element 2. Draw the image on the canvas 3. Get the canvas as a blob 4. Copy the blob to the clipboard The code…
this.setState( {newState: ‘whatever’}, () => {/*do something after the state has been updated*/} ) Here is what the above code is Doing: 1. The first argument is the new state. 2. The second argument is a callback function that will be executed after the state has been updated.
$.ajax({ type:’POST’, url:’api/v1/comments/’, // switch to the API view url contentType: ‘application/json’, // tell ajax to send it as `json` content data:{ post_id:$(‘#post_id’).val(), origin_path:$(‘#origin_path’).val(), parent_id:$(‘#parent_id’).val(), csrfmiddlewaretoken:$(‘input[name=csrfmiddlewaretoken]’).val() }, success:function(json){ Here is what the above code is Doing: 1. We’re using jQuery’s `$.ajax` method to send a POST request to the API view. 2. We’re sending the…