js remove entry
delete obj.entry;
Here is what the above code is Doing:
1. We create a new object called obj.
2. We add a property called entry to obj.
3. We delete the entry property from obj.
delete obj.entry;
Here is what the above code is Doing:
1. We create a new object called obj.
2. We add a property called entry to obj.
3. We delete the entry property from obj.
var image = new Image(); image.src = canvas.toDataURL(); Here is what the above code is Doing: 1. Create a new canvas element 2. Draw the image on the canvas 3. Get the canvas data as a data URI 4. Create a new image element 5. Set the image source to the data URI
const fs = require(‘fs’); const path = require(‘path’); let student = { name: ‘Mike’, age: 23, gender: ‘Male’, department: ‘English’, car: ‘Honda’ }; fs.writeFileSync(path.resolve(__dirname, ‘student.json’), JSON.stringify(student)); Here is what the above code is Doing: 1. We are creating a student object with some properties. 2. We are using the writeFileSync() method to write the student…
new Date().toISOString().slice(0, 16).replace(‘T’, ‘ ‘) // “2020-11-28 00:40” Here is what the above code is Doing: 1. We’re using the Date object to get the current date and time. 2. We’re using the toISOString() method to convert the date to a string. 3. We’re using the slice() method to get the first 16 characters of…
window.close() Here is what the above code is Doing: 1. It’s creating a new window. 2. It’s creating a new label. 3. It’s adding the label to the window. 4. It’s displaying the window. 5. It’s waiting for the user to click the close button. 6. It’s closing the window.
var ids = [1,2,3]; //Hundreds of elements here var names = [“john”,”doe”,”foo”]; //Hundreds of elements here var countries = [“AU”,”USA”,”USA”]; //Hundreds of elements here // Create the object array var items = ids.map((id, index) => { return { id: id, name: names[index], country: countries[index] } }); // Result var items = [ {id: 1, name:…
var randomColor = ‘#’+ Math.floor(Math.random() * 19777215).toString(16); Here is what the above code is Doing: 1. We’re creating a variable called randomColor and setting it equal to a string. 2. The string is a hexadecimal color code. 3. The hexadecimal color code is generated by concatenating a string with a random number. 4. The random…