Skip to content

Instantly share code, notes, and snippets.

View SandeepVattapparambil's full-sized avatar
🏠
Working from home

Sandeep Vattapparambil SandeepVattapparambil

🏠
Working from home
View GitHub Profile
@ryandabler
ryandabler / Object property descriptors.js
Last active June 17, 2021 00:05
Complete example of an object defined using property descriptors for this article: https://itnext.io/enhancing-javascript-objects-with-descriptors-and-symbols-2cdc95e9b422
// Create "backend" object to hold data for getters and setters on main object
const _ = Object.create( null );
Object.defineProperties(
_,
{
firstname: {
value: 'John',
writable: true,
enumerable: false,
@jeffchao
jeffchao / mappable.spec.js
Created March 28, 2013 23:58
Implementation of Array.prototype.map() in Javascript
// Run using jasmine-node.
// e.g.: jasmine-node file_name.spec.js
Array.prototype.mymap = function (callback) {
var obj = Object(this);
if (obj.length === 0) return null;
if (typeof(callback) === 'undefined') return null;
for (var i = 0, o; o = obj[i]; i++) {