title: javascript - Get position between two points by given length
body: <p>I have two points which are <code>p1</code> and <code>p2</code>.</p>
  
  <p>How can I get the position from <code>p1</code> to <code>p2</code> by a given length?</p>
  
  <pre><code>var p1 = {x: 100, y: 400};
  var p2 = {x: 300, y: 500};
  var len = 40;
  </code></pre>
  
  <p><a href="https://i.stack.imgur.com/Q7pOH.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/Q7pOH.png" alt="enter image description here"></a></p>