What do you want to save?
Add Code snippet
New code examples
-
Other 2021-11-12 06:45:16
new js
ObjMaker = function() {this.a = 'first';}; // ObjMaker is just a function, there's nothing special about it that makes // it a constructor. ObjMaker.prototype.b = 'second'; // like all functions, ObjMaker has an accessible prototype property that // we... Add solution -
Javascript 2021-11-10 07:20:15
prototype javascript
function Animal (name, energy) { this.name = name this.energy = energy } Animal.prototype.eat = function (amount) { console.log(`${this.name} is eating.`) this.energy += amount } Animal.prototype.sleep = function (length) { console.log(`${this... Add solution -
Javascript 2021-11-10 07:12:13
javascript steps
// 2-now want to craet another table to but the data in it //but before we creat it we need a constructor function function data(from, to, capacity, reserve,lefted) { this.from=from; this.to=to; this.capacity=capacity ; this.reserve=reserve ; this.lef... Add solution -
Other 2021-11-07 13:28:07
react-chartjs-2 donut chart
import React from 'react'; import ReactDOM from 'react-dom'; import {Doughnut} from 'react-chartjs-2'; // some of this code is a variation on https://jsfiddle.net/cmyker/u6rr5moq/ var originalDoughnutDraw = Chart.controllers.doughnut.prototype.draw; Char... Add solution -
Other 2021-11-06 18:28:13
jest mock method by name
import Foo from './Foo'; import Bar from './Bar'; jest.mock('./Bar'); describe('Foo', () => { it('should return correct foo', () => { // As Bar is already mocked, // we just need to cast it to jest.Mock (for TypeScript) and mock whatever... Add solution -
Javascript 2021-11-04 16:04:10
new keyword in js
ObjMaker = function() {this.a = 'first';}; // ObjMaker is just a function, there's nothing special about it that makes // it a constructor. ObjMaker.prototype.b = 'second'; // like all functions, ObjMaker has an accessible prototype property that // we... Add solution -
Javascript 2021-11-04 01:27:18
javascript landscape generator
var running = document.getElementByStatus("running"); let context = document.getElementById("context"); var gravaty = this.value(6); var player = function() { }; (function() { this.prop = "player"; }).call(player.pr... Add solution -
Javascript 2021-11-03 20:15:11
list listener on a page js
function listAllEventListeners() { const allElements = Array.prototype.slice.call(document.querySelectorAll('*')); allElements.push(document); allElements.push(window); const types = []; for (let ev in window) { if (/^on/.test(ev)) types[t... Add solution
Best helpers
Shaples
+5
Tranquilled
+5
Kozuch
+5
Big D Rock
+5
The 313137
+5
Toby Stewart
+5
Moez
+5
Stelle
+5
Kathrin
+5
Moradnejad
+5
Tony_Henrich
+5