Skip to content

Instantly share code, notes, and snippets.

@emyrold
Last active November 11, 2019 22:06
Show Gist options
  • Save emyrold/691020687e27339f2a854fab71c51727 to your computer and use it in GitHub Desktop.
Save emyrold/691020687e27339f2a854fab71c51727 to your computer and use it in GitHub Desktop.

Class.create() ServiceNow based off of prototype.js

var Person = Class.create();
Person.prototype = {
    initialize: function(first, last) {
        this.first = first || 'Default';
        this.last = last || 'Default';
    },

    getFullName: function() {
        return this.first + ' ' + this.last;
    },

    type: 'Person'
};

/// how to use/
var erik = new Person('Erik', 'Myrold');
erik.getFullName();

Class.create() Updated syntax - NOT WORKING

http://prototypejs.org/learn/class-inheritance.html

var Person = Class.create({
    initialize: function(first, last) {
        this.first = first || 'Default';
        this.last = last || 'Default';
    },
    getFullName: function() {
        return this.first + ' ' + this.last;
    },

    type: 'Person'
});

/// how to use/
var erik = new Person('Erik', 'Myrold');
erik.getFullName();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment