Skip to content

Instantly share code, notes, and snippets.

View Jagathishrex's full-sized avatar
🎯
Focusing

Jagathishrex

🎯
Focusing
View GitHub Profile
let png = canvas.toDataURL(); // default png
let jpeg = canvas.toDataURL('image/jpg');
let webp = canvas.toDataURL('image/webp');
let image = new Image();
image.onload = () => {
let canvas = document.createElement('canvas');
canvas.widht = width;
canvas.height = height;
let context = canvas.getContext('2d');
// draw image in canvas starting left-0 , top - 0
let URL = window.URL || window.webkitURL || window;
let blobURL = URL.createObjectURL(blob);
let outerHTML = clonedSvgElement.outerHTML,
blob = new Blob([outerHTML],{type:'image/svg+xml;charset=utf-8'});
let clonedSvgElement = svgElement.cloneNode(true);
// true for deep clone
var svgElement = document.getElementById('svg_element');
let {width, height} = svgElement.getBBox();
window.onerror = function(e) {
console.log("error handled", e);
}
function funcWithError() {
a; // a is not defined
}
function test() {
funcWithError();
console.log("hi"); // this will not be executed
}
function callback() {
try {
// error code
}catch
console.log("Error caught") ;
}
}
function test() {
setTimeout(callback, 1000);
}
function callback() {
// error code
}
function test() {
try {
setTimeout( callback , 1000);
} catch (e) {
console.log( "not executed" );
}
}
try {
// code with bug;
} catch {
// catch without exception argument
}