Skip to content

Instantly share code, notes, and snippets.

@aliencode
Last active December 24, 2015 15:59
Show Gist options
  • Save aliencode/6825266 to your computer and use it in GitHub Desktop.
Save aliencode/6825266 to your computer and use it in GitHub Desktop.
js 常用函数

##replace 替换/和. 为 -

function convertToid(path) {
    return  path.replace(/\.|\//g, '-')
}

##endwith

String.prototype.endWith = function(suffix) {
    return this.indexOf(suffix, this.length - suffix.length) !== -1;
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment