Skip to content

Instantly share code, notes, and snippets.

@rasmuschristensen
Created January 26, 2016 13:02
Show Gist options
  • Save rasmuschristensen/d5e677cbf860159bd119 to your computer and use it in GitHub Desktop.
Save rasmuschristensen/d5e677cbf860159bd119 to your computer and use it in GitHub Desktop.
StartsWith in javascript based on pure javascript using substring or lastIndexOf
var data = 'Just something great';
var input = 'Jus';
// this one
data.substring(0, input.length) === input;
// or this one
data.lastIndexOf(input, 0) === 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment