Q:

check coordinate exists between two points of line

I have two points, lets say x1,y1 and x2,y2. 
and i have one more point x3,y3,
here is the question, i need to check is x3,y3 coordinate occurs in the line between x1,y1 and x2,y2 or not occurs in javascript.
Thanks in advance.

A:

Try this:
var point_a = [0, 0];
var point_b = [100, 200];
var coord = [50, 100];

function checkCoordinate(coord) {
    var slope = (point_b[1] - point_a[1]) / (point_b[0] - point_a[0]);
    var newSlope = (point_b[1] - coord[1]) / (point_b[0] - coord[0]);
    if (coord[0] > point_a[0] && coord[0] < point_b[0] && coord[1] > point_a[1] && coord[1] < point_b[1] && slope == newSlope) {
        alert('Yes! they are in the same line.');
    } else {
        alert('No :/');
    }
}
checkCoordinate(coord);

Fiddle

