What do you want to save?
Add Code snippet
New code examples
-
Javascript 2021-10-26 19:42:07
how i can add the constructor to the local storage using javascript
// Extending the Storage object: Storage.prototype.setObject = function(key, value) { this.setItem(key, JSON.stringify(value)); } Storage.prototype.getObject = function(key) { var value = this.getItem(key); return value && JSON.parse(... Add solution -
Javascript 2021-10-26 15:35:11
angular9 spy
it("should be able to upper case a string", function () { var spytoUpperCase = spyOn(String.prototype, 'toUpperCase') expect(utils.toUpperCase).toBeDefined(); expect(utils.toUpperCase("hello world")).toEqual("HELLO WORLD")... Add solution -
Javascript 2021-10-23 23:23:11
how to add a letter to a string javascript
String.prototype.splice = function(idx, rem, str) { return this.slice(0, idx) + str + this.slice(idx + Math.abs(rem)); }; var result = "foo baz".splice(4, 0, "bar "); document.body.innerHTML = result; // "foo bar baz" Add solution -
Javascript 2021-10-21 15:12:16
JavaScript does not protect the property name hasOwnProperty
// hasOwnProperty – JavaScript does not protect var foo = { // overriding foo's default hasOwnProperty method hasOwnProperty: function() { return false; }, bar: 'data' }; foo.hasOwnProperty('bar'); // false always // Hence, ... Add solution -
Javascript 2021-10-19 08:43:10
inheritance in 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 -
Html 2021-10-16 22:57:04
input date default value html
<!-- HTML --> <input type="date" id="theDate"> <script> // JQuery $(document).ready( function() { $('#theDate').val(new Date().toDateInputValue()); }); // Pure JS document.getElementById('theDate').v... Add solution -
Javascript 2021-10-16 18:59:13
hasownproperty.call
var foo = { hasOwnProperty: function() { return false; }, bar: 'Here be dragons' }; foo.hasOwnProperty('bar'); // always returns false // Use another Object's hasOwnProperty // and call it with 'this' set to foo ({}).hasOwnProperty.call(foo, '... Add solution -
Javascript 2021-10-16 10:20:08
merge array of objects javascript
var arr1 = [{name: "lang", value: "English"},{name: "age", value: "18"}]; var arr2 = [{name : "childs", value: '5'}, {name: "lang", value: "German"}]; Array.prototype.push.apply(arr1,a... Add solution
Best helpers
+5
+5
+5
+5
+5
+5
+5
+5
+5
+5
+5